Skip to content

Add a (mostly) full Task FFI from TaskChampion#4117

Merged
djmitche merged 5 commits into
GothenburgBitFactory:developfrom
carmiac:task_ffi
Jul 19, 2026
Merged

Add a (mostly) full Task FFI from TaskChampion#4117
djmitche merged 5 commits into
GothenburgBitFactory:developfrom
carmiac:task_ffi

Conversation

@carmiac

@carmiac carmiac commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

This adds a mostly complete Task FFI from TaskChampion. It also adds the Replica functions dealing with Tasks.

It does not include:

  • deprecated functions or features
  • Task::into_task_data
  • Replica::dependancy_map

Nor does it actually connect any of this to the TaskWarrior logic.

@carmiac carmiac changed the title Add a full Task FFI from TaskChampion Add a (mostly) full Task FFI from TaskChampion Jun 3, 2026
@djmitche
djmitche self-requested a review June 13, 2026 18:36
@djmitche

Copy link
Copy Markdown
Collaborator

I apologize for my tardiness in looking at this!

@djmitche djmitche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'm sorry for taking well over a month to review this. It looks great, with just a few very minor updates below. Otherwise I'm happy with this, but I would like to understand what the next step is before doing so. What's the benefit of this approach over the lower-level TaskData type?

Comment thread src/taskchampion-cpp/src/lib.rs Outdated

/// Add a tag to the task. The tag is parsed from a string, so can fail.
fn add_tag(self: &mut Task, tag: &CxxString, ops: &mut Vec<Operation>) -> Result<()>;
/// Remove a tag from the task. The tag is parsed from a, so can fail.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Remove a tag from the task. The tag is parsed from a, so can fail.
/// Remove a tag from the task. The tag is parsed from a string, so can fail.

Comment thread src/taskchampion-cpp/src/lib.rs Outdated
Comment on lines +149 to +150
/// This contains `OptionTaskData` to allow C++ to `take` values out of the vector and use
/// them as `rust::Box<TaskData>`. Cxx does not support `Vec<Box<_>>`. Cxx also does not

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This contains `OptionTaskData` to allow C++ to `take` values out of the vector and use
/// them as `rust::Box<TaskData>`. Cxx does not support `Vec<Box<_>>`. Cxx also does not
/// This contains `OptionTask` to allow C++ to `take` values out of the vector and use
/// them as `rust::Box<Task>`. See the comments on `all_task_data`.

Comment thread src/taskchampion-cpp/src/lib.rs Outdated
Comment on lines +1226 to +1230
if let Some(t) = self.0.get_entry() {
t.timestamp()
} else {
0
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A helper function for this -- inverse of optional_timestamp -- might be useful.

Comment thread src/taskchampion-cpp/src/lib.rs Outdated
ffi::Status::Completed => tc::Status::Completed,
ffi::Status::Deleted => tc::Status::Deleted,
ffi::Status::Recurring => tc::Status::Recurring,
_ => unreachable!("ffi::Status variants are exhaustive"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually unreachable, though -- t.set_status(ffi::Status::Unknown, ops) will reach this point. So I don't think it should panic. It might make sense to treat this as an error, since we can't round-trip the Unknown(value) variant from Rust.

Comment thread src/taskchampion-cpp/src/lib.rs
@carmiac

carmiac commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Again, I'm sorry for taking well over a month to review this. It looks great, with just a few very minor updates below. Otherwise I'm happy with this, but I would like to understand what the next step is before doing so. What's the benefit of this approach over the lower-level TaskData type?

Oh I get it, it's been a rough month for me. This is one part of splitting up #4113

Iterative tasks need to be handled by Task::set_status and other Task functions, rather than directly manipulating TaskData so that they are always handled the same way. I threw in the rest of the Task interface since I was already there.

@djmitche

Copy link
Copy Markdown
Collaborator

Gotcha - thanks!

@djmitche djmitche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@djmitche
djmitche merged commit da8c555 into GothenburgBitFactory:develop Jul 19, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants