pub struct Id { /* private fields */ }
Expand description

This is the Id type, that uniquely identifies slices of bytes, in rust equivalent to &[u8]. As in the case with &[u8] the length is also encoded in the type, making it a kind of a fat-pointer for content addressed byte-slices.

The length of the corresponding byte-string is encoded in the first two bytes in big endian.

If the length of the byteslice is less than or equal to 32 bytes, the bytes are stored directly inline in the bytes field.

Proposal: The trailing bytes in an inlined value MUST be set to zero

Implementations

Creates a new Id from a type

Returns the computed hash of the value.

Note that this is different from the payload itself in case of an inlined value, that normally does not get hashed.

Useful for giving a well-distributed unique id for all Canon types, for use in hash maps for example.

Returns the bytes of the identifier

Consumes the Id and returns the payload bytes

Returns the length of the represented data

Attempts to reify the Id as an instance of type T

Takes the bytes corresponding to this id out of the underlying store.

If the Id is inlined, this is a no-op and returns Ok(None)

Trait Implementations

Generate an arbitrary value of Self from the given unstructured data. Read more

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more

Write the encoded value as bytes to a Sink

Return the decoded value from bytes in a Source

Returns the number of bytes needed to encode this value

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.