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

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

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

impl Path[src]

pub fn hash(&self) -> ExternResult<EntryHash>[src]

What is the hash for the current Path ?

pub fn exists(&self) -> ExternResult<bool>[src]

Does an entry exist at the hash we expect?

pub fn ensure(&self) -> ExternResult<()>[src]

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

pub fn parent(&self) -> Option<Path>[src]

pub fn children(&self) -> ExternResult<Links>[src]

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.

pub fn children_details(&self) -> ExternResult<LinkDetails>[src]

Trait Implementations

impl AsRef<Vec<Component, Global>> for Path[src]

Access components vector.

impl Clone for Path[src]

impl Debug for Path[src]

impl Default for Path[src]

impl<'de> Deserialize<'de> for Path[src]

impl EntryDefRegistration for Path[src]

impl From<&'_ Anchor> for Path[src]

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.

impl From<&'_ Path> for EntryDef where
    Path: EntryDefRegistration
[src]

impl From<&'_ Path> for EntryDefId where
    Path: EntryDefRegistration
[src]

impl From<&'_ Path> for EntryVisibility where
    Path: EntryDefRegistration
[src]

impl From<&'_ Path> for CrdtType where
    Path: EntryDefRegistration
[src]

impl From<&'_ Path> for RequiredValidations where
    Path: EntryDefRegistration
[src]

impl From<&'_ String> for Path[src]

Alias From<&str>

impl From<&'_ str> for Path[src]

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.

impl From<(&'_ ShardStrategy, &'_ [u8])> for Path[src]

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.

impl From<(&'_ ShardStrategy, &'_ String)> for Path[src]

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

impl From<(&'_ ShardStrategy, &'_ Vec<u8, Global>)> for Path[src]

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

impl From<(&'_ ShardStrategy, &'_ str)> for Path[src]

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.

impl From<(&'_ ShardStrategy, String)> for Path[src]

impl From<(&'_ ShardStrategy, Vec<u8, Global>)> for Path[src]

Wrapper around Vec to work the same as &u8.

impl From<Path> for EntryDef where
    Path: EntryDefRegistration
[src]

impl From<Path> for EntryDefId where
    Path: EntryDefRegistration
[src]

impl From<Path> for EntryVisibility where
    Path: EntryDefRegistration
[src]

impl From<Path> for CrdtType where
    Path: EntryDefRegistration
[src]

impl From<Path> for RequiredValidations where
    Path: EntryDefRegistration
[src]

impl From<Path> for Vec<Component>[src]

Unwrap components vector.

impl From<String> for Path[src]

Alias From<&str>

impl From<Vec<Component, Global>> for Path[src]

Wrap components vector.

impl PartialEq<Path> for Path[src]

impl Serialize for Path[src]

impl StructuralPartialEq for Path[src]

impl TryFrom<&'_ Entry> for Path[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<&'_ LinkTag> for Path[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<&'_ Path> for Anchor[src]

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.

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<&'_ Path> for SerializedBytes[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<&'_ Path> for Entry[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<&'_ Path> for EntryWithDefId where
    Path: EntryDefRegistration
[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<&'_ Path> for LinkTag[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<Entry> for Path[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<Path> for SerializedBytes[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<Path> for Entry[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<Path> for EntryWithDefId[src]

type Error = WasmError

The type returned in the event of a conversion error.

impl TryFrom<SerializedBytes> for Path[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Path

impl Send for Path

impl Sync for Path

impl Unpin for Path

impl UnwindSafe for Path

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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