pub struct ThingsId(/* private fields */);Expand description
Identifier for any Things 3 entity (task, project, area, tag, heading).
Things 3 uses two distinct identifier formats in the wild:
- Native Things IDs — 21- or 22-character base62 strings the Things
app itself produces (e.g.
R4t2G8Q63aGZq4epMHNeCr). These appear on every entity created via the Things UI or viaosascript. - RFC-4122 UUIDs — 36-character hyphenated hex strings that the
SqlxBackendgenerates for entities created through rust-things3 (e.g.9d3f1e44-5c2a-4b8e-9c1f-7e2d8a4b3c5e).
Both formats coexist in the same SQLite uuid column. This type stores
whichever format the entity was created with — never lossy conversion,
always round-trip-safe through osascript, the database, and JSON wire
format.
#[serde(transparent)] means the JSON shape is unchanged from when the
type was Uuid: a bare string field, no enum tagging.
§Validation boundary
serde deserialization (via #[serde(transparent)]) accepts any string
and does not call from_str — it calls from_trusted semantics. This is
intentional: request structs deserialized from the DB or from AppleScript output
already contain trusted values. If you add a new code path that deserializes a
request struct containing ThingsId fields directly from untrusted JSON (e.g. a
new HTTP handler), call ThingsId::from_str explicitly on each ID field before
acting on it rather than relying on serde to validate.
§Construction
ThingsId::new_v4— fresh hyphenated UUID, used bySqlxBackendThingsId::from_str— strict parse, rejects anything that isn’t one of the two known formats; used at MCP boundariesFrom<Uuid>— infallible, wraps a UUID’s hyphenated form
Implementations§
Source§impl ThingsId
impl ThingsId
Sourcepub fn new_v4() -> Self
pub fn new_v4() -> Self
Generate a fresh hyphenated UUID, suitable for SqlxBackend-created
entities.
Sourcepub fn new_things_native() -> Self
pub fn new_things_native() -> Self
Generate a fresh Things-native 22-char Base62 ID. Use this for any
new entity that may be referenced via AppleScript — Things 3’s
AppleScript dictionary only accepts this format in to do id "..."
references, so a hyphenated UUID would fail with -1728 (#148).
Internally derived from a v4 UUID’s 16 random bytes, base62-encoded (a 16-byte / 128-bit value fits in 22 base62 characters).
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Borrow the underlying string (for SQL parameter binding, AppleScript interpolation, logging, etc.).
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consume into the owned String.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ThingsId
impl<'de> Deserialize<'de> for ThingsId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromStr for ThingsId
impl FromStr for ThingsId
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Strict parse. Accepts:
- Hyphenated RFC-4122 UUIDs (36 chars)
- Things native IDs (21 or 22 base62 chars)
Anything else returns a ThingsError::Validation so MCP callers see a
clear error before the request hits the database.
Source§type Err = ThingsError
type Err = ThingsError
Source§impl Ord for ThingsId
impl Ord for ThingsId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ThingsId
impl PartialOrd for ThingsId
impl Eq for ThingsId
impl StructuralPartialEq for ThingsId
Auto Trait Implementations§
impl Freeze for ThingsId
impl RefUnwindSafe for ThingsId
impl Send for ThingsId
impl Sync for ThingsId
impl Unpin for ThingsId
impl UnsafeUnpin for ThingsId
impl UnwindSafe for ThingsId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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