add task_import_with_uuid

This commit is contained in:
Dustin J. Mitchell 2022-01-26 01:49:06 +00:00
parent 96b59dd5b2
commit f3b73ca0e4
3 changed files with 52 additions and 4 deletions

View file

@ -1,5 +1,5 @@
use crate::{result::TCResult, status::TCStatus, string::TCString, task::TCTask};
use taskchampion::{Replica, StorageConfig};
use crate::{result::TCResult, status::TCStatus, string::TCString, task::TCTask, uuid::TCUuid};
use taskchampion::{Replica, StorageConfig, Uuid};
/// A replica represents an instance of a user's task data, providing an easy interface
/// for querying and modifying that data.
@ -89,7 +89,7 @@ pub extern "C" fn tc_replica_new_on_disk<'a>(
///
/// Returns the task, or NULL on error.
#[no_mangle]
pub extern "C" fn tc_replica_new_task<'a>(
pub extern "C" fn tc_replica_new_task(
rep: *mut TCReplica,
status: TCStatus,
description: *mut TCString,
@ -105,7 +105,25 @@ pub extern "C" fn tc_replica_new_task<'a>(
)
}
// TODO: tc_replica_import_task_with_uuid
/// Create a new task. The task must not already exist.
///
/// Returns the task, or NULL on error.
#[no_mangle]
pub extern "C" fn tc_replica_import_task_with_uuid(
rep: *mut TCReplica,
uuid: TCUuid,
) -> *mut TCTask {
wrap(
rep,
|rep| {
let uuid: Uuid = uuid.into();
let task = rep.import_task_with_uuid(uuid)?;
Ok(TCTask::as_ptr(task))
},
std::ptr::null_mut(),
)
}
// TODO: tc_replica_sync
/// Undo local operations until the most recent UndoPoint.

View file

@ -93,6 +93,13 @@ struct TCTask *tc_replica_new_task(struct TCReplica *rep,
enum TCStatus status,
struct TCString *description);
/**
* Create a new task. The task must not already exist.
*
* Returns the task, or NULL on error.
*/
struct TCTask *tc_replica_import_task_with_uuid(struct TCReplica *rep, struct TCUuid uuid);
/**
* Undo local operations until the most recent UndoPoint.
*