#[repr(transparent)]pub struct Path(_);
Expand description
A Path
is a vector of Component
s.
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
sourceimpl Path
impl Path
sourcepub fn into_typed(self, link_type: impl Into<ScopedLinkType>) -> TypedPath
pub fn into_typed(self, link_type: impl Into<ScopedLinkType>) -> TypedPath
Attach a LinkType
to this path
so its type is known for create_link
and get_links
.
sourcepub fn typed<TY, E>(self, link_type: TY) -> Result<TypedPath, WasmError>where
ScopedLinkType: TryFrom<TY, Error = E>,
WasmError: From<E>,
pub fn typed<TY, E>(self, link_type: TY) -> Result<TypedPath, WasmError>where
ScopedLinkType: TryFrom<TY, Error = E>,
WasmError: From<E>,
Try attaching a LinkType
to this path
so its type is known for create_link
and get_links
.
sourcepub fn path_entry_hash(&self) -> ExternResult<EntryHash>
pub fn path_entry_hash(&self) -> ExternResult<EntryHash>
What is the hash for the current Path
?
sourcepub fn append_component(&mut self, component: Component)
pub fn append_component(&mut self, component: Component)
Mutate this Path
into a child of itself by appending a Component
.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
sourcefn 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
sourceimpl From<&Anchor> for Path
impl From<&Anchor> for Path
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.
sourceimpl From<&str> for Path
impl From<&str> for Path
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.
sourceimpl From<(&ShardStrategy, &[u8])> for Path
impl From<(&ShardStrategy, &[u8])> for Path
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.
sourcefn from((strategy, bytes): (&ShardStrategy, &[u8])) -> Path
fn from((strategy, bytes): (&ShardStrategy, &[u8])) -> Path
Converts to this type from the input type.
sourceimpl From<(&ShardStrategy, &String)> for Path
impl From<(&ShardStrategy, &String)> for Path
sourcefn from((strategy, s): (&ShardStrategy, &String)) -> Path
fn from((strategy, s): (&ShardStrategy, &String)) -> Path
Converts to this type from the input type.
sourceimpl From<(&ShardStrategy, &Vec<u8, Global>)> for Path
impl From<(&ShardStrategy, &Vec<u8, Global>)> for Path
Wrapper around &Vec
sourceimpl From<(&ShardStrategy, &str)> for Path
impl From<(&ShardStrategy, &str)> for Path
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.
sourcefn from((strategy, s): (&ShardStrategy, &str)) -> Path
fn from((strategy, s): (&ShardStrategy, &str)) -> Path
Converts to this type from the input type.
sourceimpl From<(&ShardStrategy, String)> for Path
impl From<(&ShardStrategy, String)> for Path
sourcefn from((strategy, s): (&ShardStrategy, String)) -> Path
fn from((strategy, s): (&ShardStrategy, String)) -> Path
Converts to this type from the input type.
sourceimpl From<(&ShardStrategy, Vec<u8, Global>)> for Path
impl From<(&ShardStrategy, Vec<u8, Global>)> for Path
Wrapper around Vec
sourceimpl PartialEq<Path> for Path
impl PartialEq<Path> for Path
sourceimpl TryFrom<&Path> for Anchor
impl TryFrom<&Path> for Anchor
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.
sourceimpl TryFrom<&Path> for SerializedBytes
impl TryFrom<&Path> for SerializedBytes
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(t: &Path) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: &Path) -> Result<SerializedBytes, SerializedBytesError>
Performs the conversion.
sourceimpl TryFrom<Path> for SerializedBytes
impl TryFrom<Path> for SerializedBytes
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(t: Path) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: Path) -> Result<SerializedBytes, SerializedBytesError>
Performs the conversion.
sourceimpl TryFrom<SerializedBytes> for Path
impl TryFrom<SerializedBytes> for Path
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(sb: SerializedBytes) -> Result<Path, SerializedBytesError>
fn try_from(sb: SerializedBytes) -> Result<Path, SerializedBytesError>
Performs the conversion.
impl StructuralPartialEq for Path
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> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn 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;
T: Future, type Output = <T as Future>::Output;
sourcefn 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;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn 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>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn 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;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more