Skip to main content

RecordId

Struct RecordId 

pub struct RecordId(/* private fields */);
Expand description

The stable identity of a record. Encoded by prefix: file-record:<uuid> (a file, by the durable id its filesystem record carries — see RecordId::identify_file), file:<absolute path> (a file known only by where it is: a not-yet-written Save As target, or a filesystem that can’t hold the durable id), uuid:<uuid> (minted, for a record with no natural name), tab:<tab id> (a window’s scratch document until a file names it, see RecordId::for_tab) and derived:<role>@<id> (see RecordId::derived).

§Files

A file’s identity is its file record, never its path or its bytes:

  • Rename and move keep it. The collaborative filesystem keys files by a FileRecordId that survives rename and move and serves it as the user.tilo.record-id attribute; elsewhere the same attribute is written once on first open and travels with the inode.
  • A copy is a new file. The filesystem mints a new record for a created file, and a plain local copy does not carry the attribute, so a copy starts with its own records. That is deliberate: copying is how a person forks a document — to send a clean version, or to try different edits — and mirroring every note into the copy would surprise them and leak notes into what they hand on. Tools asked to preserve extended attributes (cp -a, rsync -X) are an explicit request to keep the identity, and do.
  • Identical bytes are not the same file. Nothing here is derived from content, so two files with the same bytes never share edits by accident. Content that should be shared by bytes is a blob reference instead (add_blob_reference).

The prefix is part of the id, not a tag beside it: the id travels on the wire and names a file on disk, so it must be self-describing.

Implementations§

§

impl RecordId

pub fn package_primary() -> RecordId

Internal custody key for a package’s existing room-primary document. It never travels as a record id on the collaboration wire.

pub fn is_package_primary(&self) -> bool

pub fn for_file(path: impl AsRef<Path>) -> RecordId

The record a file is. Relative paths resolve against the cwd, so two spellings of one file are one record.

The id embeds the absolute path, so two peers reach one record only if the file sits at the same path on both. Don’t use this for content embedded in a document (a dropped image) — that needs a content-addressed record, not a path-addressed one.

pub fn for_file_record(id: Uuid) -> RecordId

The record of the file whose filesystem record id is id — the collaborative filesystem’s FileRecordId, or the id Self::identify_file wrote for a file elsewhere.

pub fn identify_file(path: impl AsRef<Path>) -> RecordId

The durable identity of the file at path, so reopening it after a rename or move reaches the same records.

Reads the file’s user.tilo.record-id attribute (16 raw bytes — the collaborative filesystem serves its FileRecordId there; on macOS, where every copy inherits the attribute, the id is followed by the inode it belongs to so a copy is told apart). A file without one, on a filesystem that accepts user attributes, gets a freshly minted id written with create-only semantics (a concurrent opener that wins the race is re-read, so both agree). Anything else — no attribute support, a read-only file, not a regular file — falls back to the path identity Self::for_file: the best identity the file can carry.

Two system calls at most besides the metadata lookup; call it off the UI thread when the file might be on a network filesystem.

pub fn minted() -> RecordId

pub fn for_tab(tab: u64) -> RecordId

Reuses the tab id rather than minting a new one: it’s already unique per machine and persisted with the window tree, so a separate id beside it could only drift.

pub fn room_default() -> RecordId

The record an app opens in a room when nothing names another one: the first window of the app on any device of the room, native or browser, so they all meet on one document. Constant, so every device derives the same id without asking; the room scopes it.

pub fn derived(role: &str, of: &RecordId) -> RecordId

Identity of the record that plays role for of — “the annotations of this document”. Distinct from its target so the two can be shared separately: handing over the document doesn’t hand the notes.

pub fn parse(s: &str) -> Option<RecordId>

Adopt an id read back from a document, a room index, or the wire. Invalid, oversized, or non-canonical names fail closed: IDs name collaboration routes and storage directories, so accepting arbitrary strings here would turn a room index into an allocation oracle.

pub fn uri(&self) -> String

The URI asking an app to open this record ([collab_types::RECORD_URI_SCHEME]).

pub fn from_uri(uri: &str) -> Option<RecordId>

The record a Self::uri names.

pub fn as_str(&self) -> &str

pub fn file_path(&self) -> Option<PathBuf>

The path a file record names, if it is one.

pub fn file_record(&self) -> Option<Uuid>

The filesystem record id of a file-record: identity.

pub fn storage_key(&self) -> String

A filesystem-safe directory name for this record’s document. Must be stable (same record → same directory next launch, or data is silently orphaned) and collision-free (two records sharing a directory merge their documents) — hence a readable sanitised prefix plus a hash of the whole id, which is what actually distinguishes them.

Trait Implementations§

§

impl Clone for RecordId

§

fn clone(&self) -> RecordId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for RecordId

§

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

Formats the value using the given formatter. Read more
§

impl Display for RecordId

§

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

Formats the value using the given formatter. Read more
§

impl Hash for RecordId

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl Ord for RecordId

§

fn cmp(&self, other: &RecordId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for RecordId

§

fn eq(&self, other: &RecordId) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for RecordId

§

fn partial_cmp(&self, other: &RecordId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Eq for RecordId

§

impl StructuralPartialEq for RecordId

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,