#[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
sourceimpl Path
impl Path
pub fn path_entry(&self) -> ExternResult<PathEntry>
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 exists(&self) -> ExternResult<bool>
pub fn exists(&self) -> ExternResult<bool>
Does an entry exist at the hash we expect?
sourcepub fn ensure(&self) -> ExternResult<()>
pub fn ensure(&self) -> ExternResult<()>
Recursively touch this and every parent that doesn’t exist yet.
sourcepub fn parent(&self) -> Option<Path>
pub fn parent(&self) -> Option<Path>
The parent of the current path is simply the path truncated one level.
sourcepub fn children(&self) -> ExternResult<Vec<Link>>
pub fn children(&self) -> ExternResult<Vec<Link>>
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.
sourcepub fn children_paths(&self) -> ExternResult<Vec<Self>>
pub fn children_paths(&self) -> ExternResult<Vec<Self>>
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.
pub fn children_details(&self) -> ExternResult<LinkDetails>
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 EntryDefRegistration for Path
impl EntryDefRegistration for Path
fn entry_def() -> EntryDef
fn entry_def_id() -> EntryDefId
fn entry_visibility() -> EntryVisibility
fn crdt_type() -> CrdtType
fn required_validations() -> RequiredValidations
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<&'_ Path> for EntryDefId where
Path: EntryDefRegistration,
impl From<&'_ Path> for EntryDefId where
Path: EntryDefRegistration,
sourceimpl From<&'_ Path> for EntryVisibility where
Path: EntryDefRegistration,
impl From<&'_ Path> for EntryVisibility where
Path: EntryDefRegistration,
sourceimpl From<&'_ Path> for RequiredValidations where
Path: EntryDefRegistration,
impl From<&'_ Path> for RequiredValidations where
Path: EntryDefRegistration,
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.
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
sourceimpl From<(&'_ ShardStrategy, Vec<u8, Global>)> for Path
impl From<(&'_ ShardStrategy, Vec<u8, Global>)> for Path
Wrapper around Vec
sourceimpl From<Path> for EntryDefId where
Path: EntryDefRegistration,
impl From<Path> for EntryDefId where
Path: EntryDefRegistration,
sourceimpl From<Path> for EntryVisibility where
Path: EntryDefRegistration,
impl From<Path> for EntryVisibility where
Path: EntryDefRegistration,
sourceimpl From<Path> for RequiredValidations where
Path: EntryDefRegistration,
impl From<Path> for RequiredValidations where
Path: EntryDefRegistration,
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 AppEntryBytes
impl TryFrom<&'_ Path> for AppEntryBytes
sourceimpl TryFrom<&'_ Path> for CreateInput where
Path: EntryDefRegistration,
impl TryFrom<&'_ Path> for CreateInput where
Path: EntryDefRegistration,
sourceimpl TryFrom<HoloHashed<Entry>> for Path
impl TryFrom<HoloHashed<Entry>> for Path
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 AppEntryBytes
impl TryFrom<Path> for AppEntryBytes
sourceimpl TryFrom<Path> for CreateInput
impl TryFrom<Path> for CreateInput
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
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