better docs for C

This commit is contained in:
Dustin J. Mitchell
2022-02-16 01:01:35 +00:00
parent b1d537ac87
commit 741cb84430
6 changed files with 191 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ use std::str::Utf8Error;
/// When a `*TCString` appears as a return value or output argument, ownership is passed to the
/// caller. The caller must pass that ownership back to another function or free the string.
///
/// Any function taking a `*TCReplica` requires:
/// Any function taking a `*TCString` requires:
/// - the pointer must not be NUL;
/// - the pointer must be one previously returned from a tc_… function; and
/// - the memory referenced by the pointer must never be modified by C code.

View File

@@ -7,6 +7,22 @@ use taskchampion::{Uuid, WorkingSet};
/// be freed at any time.
///
/// To iterate over a working set, search indexes 1 through largest_index.
///
/// # Safety
///
/// The `*TCWorkingSet` returned from `tc_replica_working_set` is owned by the caller and
/// must later be freed to avoid a memory leak. Its lifetime is independent of the replica
/// from which it was generated.
///
/// Any function taking a `*TCWorkingSet` requires:
/// - the pointer must not be NUL;
/// - the pointer must be one previously returned from `tc_replica_working_set`
/// - the memory referenced by the pointer must never be accessed by C code; and
/// - except for `tc_replica_free`, ownership of a `*TCWorkingSet` remains with the caller.
///
/// Once passed to `tc_replica_free`, a `*TCWorkingSet` becomes invalid and must not be used again.
///
/// TCWorkingSet is not threadsafe.
pub struct TCWorkingSet(WorkingSet);
impl PassByPointer for TCWorkingSet {}