#[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”.
Note that the Path
is not literally committed and/or linked from/to as
base and target. For this the PathEntry
exists, which achieves a
constant size for the DHT representation of each node of the Path
.
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 path to paths below it. Only returns links between paths, not to other entries that might have their own links.
Touch and list all the links from this path to paths below it.
Same as Path::children
but returns Vec<Path>
rather than Vec<Link>
.
This is more than just a convenience. In general it’s not possible to
construct a full Path
from a child Link
alone as only a single
Component
is encoded into the link tag. To build a full child path
the parent path + child link must be combined, which this function does
to produce each child, by using &self
as that parent.
Mutate this Path
into a child of itself by appending a Component
.
Trait Implementations
Access components vector.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
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.
Alias From<&str>
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
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.
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.
Wrapper around &Vec
Wrapper around Vec
Unwrap components vector.
Alias From<&str>
Wrap components vector.
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
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for Path
impl UnwindSafe for Path
Blanket Implementations
Mutably borrows from an owned value. Read more
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more