Struct TCString

Source
#[repr(C)]
pub struct TCString { /* private fields */ }
Expand description

***** TCString *****

TCString supports passing strings into and out of the TaskChampion API.

§Rust Strings and C Strings

A Rust string can contain embedded NUL characters, while C considers such a character to mark the end of a string. Strings containing embedded NULs cannot be represented as a “C string” and must be accessed using tc_string_content_and_len and tc_string_clone_with_len. In general, these two functions should be used for handling arbitrary data, while more convenient forms may be used where embedded NUL characters are impossible, such as in static strings.

§UTF-8

TaskChampion expects all strings to be valid UTF-8. tc_string_… functions will fail if given a *TCString containing invalid UTF-8.

§Safety

The ptr field may be checked for NULL, where documentation indicates this is possible. All other fields in a TCString are private and must not be used from C. They exist in the struct to ensure proper allocation and alignment.

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 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.

Unless specified otherwise, TaskChampion functions take ownership of a TCString when it is given as a function argument, and the caller must not use or free TCStrings after passing them to such API functions.

A TCString with a NULL ptr field need not be freed, although tc_free_string will not fail for such a value.

TCString is not threadsafe.

typedef struct TCString {
  void *ptr;   // opaque, but may be checked for NULL
  size_t _u1;  // reserved
  size_t _u2;  // reserved
  uint8_t _u3; // reserved
} TCString;

Trait Implementations§

Source§

impl Debug for TCString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TCString

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,