#[repr(transparent)]
pub struct Path(_);
Expand description

A Path is a vector of Component . It represents a single traversal of a tree structure down to some arbitrary point. The main intent is that we can recursively walk back up the tree, hashing, committing and linking each sub-path along the way until we reach the root. At this point it is possible to follow DHT links from the root back up the path. i.e. the ahead-of-time predictability of the hashes of a given path allows us to travel “up” the tree and the linking functionality of the holochain DHT allows us to travel “down” the tree after at least one DHT participant has followed the path “up”.

Implementations

Attach a LinkType to this path so its type is known for create_link and get_links.

Try attaching a LinkType to this path so its type is known for create_link and get_links.

source

pub fn path_entry_hash(&self) -> ExternResult<EntryHash>

What is the hash for the current Path ?

Mutate this Path into a child of itself by appending a Component.

Accessor for the last Component of this Path. This can be thought of as the leaf of the implied tree structure of which this Path is one branch of.

Make the LinkTag for this Path.

Check if this Path is the root.

Trait Implementations

Access components vector.

Converts this type into a shared reference of the (usually inferred) input type.

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

Deserialize this value from the given Serde deserializer. Read more

Anchors are just a special case of path, so we can move from anchor to path losslessly. We simply format the anchor structure into a string that works with the path string handling.

Converts to this type from the input type.

Alias From<&str>

Converts to this type from the input type.

Split a string path out into a vector of components. This allows us to construct pseudo-URI-path-things as strings. It is a simpler scheme than URLs and file paths. Leading and trailing slashes are ignored as are duplicate dots and the empty string leads to a path with zero length (no components).

e.g. all the following result in the same components as vec!["foo", "bar"] (as bytes)

  • foo.bar
  • foo.bar.
  • .foo.bar
  • .foo.bar.
  • foo..bar

There is no normalisation of paths, e.g. to guarantee a specific root component exists, at this layer so there is a risk that there are hash collisions with other data on the DHT network if some disambiguation logic is not included in higher level abstractions.

This supports sharding strategies from a small inline DSL. Start each component with :# to get shards out of the string.

e.g.

  • foo.barbaz => normal path as above [“foo”, “barbaz”]
  • foo.1:3#barbazii => width 1, depth 3, [“foo”, “b”, “a”, “r”, “barbazii”]
  • foo.2:3#barbazii => width 2, depth 3, [“foo”, “ba”, “rb”, “az”, “barbazii”]

Note that this all works because the components and sharding for strings maps to fixed-width utf32 bytes under the hood rather than variable width bytes.

Converts to this type from the input type.

Builds a path for a shard strategy and some binary bytes. This is the trivial case, we just split the bytes out one by one and make a path from it.

Converts to this type from the input type.

&String wrapper mimicking &str for Path building.

Converts to this type from the input type.

Wrapper around &Vec to work the same as &u8.

Converts to this type from the input type.

Create Path from String . To ensure that this works for all utf8, which can have anywhere from 1-4 bytes for a single character, we first represent each character as a utf32 so it gets padded out with 0 bytes. This means the width is 4x what it would be for raw bytes with the same strategy.

Converts to this type from the input type.

Converts to this type from the input type.

Wrapper around Vec to work the same as &u8.

Converts to this type from the input type.

Unwrap components vector.

Converts to this type from the input type.

Alias From<&str>

Converts to this type from the input type.

Converts to this type from the input type.

Wrap components vector.

Converts to this type from the input type.

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

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Paths are more general than anchors so a path could be represented that is not a valid anchor. The obvious example would be a path of binary data that is not valid utf-8 strings or a path that is more than 2 levels deep.

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.

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The archived version of the pointer metadata for this type.

Converts some archived metadata to the pointer metadata for itself.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Deserializes using the given deserializer

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The type for metadata in pointers and references to Self.

The resulting type after obtaining ownership.

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

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.

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

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