Struct hdk::hash_path::path::Path[][src]

#[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

What is the hash for the current Path ?

Does an entry exist at the hash we expect?

Recursively touch this and every parent that doesn’t exist yet.

The parent of the current path is simply the path truncated one level.

Touch and list all the links from this anchor to anchors below it. Only returns links between anchors, not to other entries that might have their own links.

Trait Implementations

Access components vector.

Performs the conversion.

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.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Alias From<&str>

Performs the conversion.

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.

Performs the conversion.

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.

Performs the conversion.

[ &String ] wrapper mimicing &str for Path building.

Performs the conversion.

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

Performs the conversion.

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.

Performs the conversion.

Performs the conversion.

Wrapper around Vec to work the same as &u8.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Unwrap components vector.

Performs the conversion.

Alias From<&str>

Performs the conversion.

Wrap components vector.

Performs the conversion.

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

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.

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.

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.

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

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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)

recently added

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.