Struct hdk::hash_path::path::Path [−][src]
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl EntryDefRegistration for Path
[src]
fn entry_def() -> EntryDef
[src]
fn entry_def_id() -> EntryDefId
[src]
fn entry_visibility() -> EntryVisibility
[src]
fn crdt_type() -> CrdtType
[src]
fn required_validations() -> RequiredValidations
[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]
Path: EntryDefRegistration,
impl From<&'_ Path> for EntryDefId where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<&'_ Path> for EntryVisibility where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<&'_ Path> for CrdtType where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<&'_ Path> for RequiredValidations where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
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
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]
impl From<(&'_ ShardStrategy, &'_ Vec<u8, Global>)> for Path
[src]
Wrapper around &Vec
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
impl From<Path> for EntryDef where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<Path> for EntryDefId where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<Path> for EntryVisibility where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<Path> for CrdtType where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
impl From<Path> for RequiredValidations where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
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]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Path
[src]
impl TryFrom<&'_ Entry> for Path
[src]
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(entry: &Entry) -> Result<Self, Self::Error>
[src]
impl TryFrom<&'_ LinkTag> for Path
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(link_tag: &LinkTag) -> Result<Self, Self::Error>
[src]
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.
fn try_from(path: &Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<&'_ Path> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: &Path) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl TryFrom<&'_ Path> for Entry
[src]
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(t: &Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<&'_ Path> for EntryWithDefId where
Path: EntryDefRegistration,
[src]
Path: EntryDefRegistration,
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(t: &Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<&'_ Path> for LinkTag
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(path: &Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<Entry> for Path
[src]
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(entry: Entry) -> Result<Self, Self::Error>
[src]
impl TryFrom<Path> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: Path) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl TryFrom<Path> for Entry
[src]
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(t: Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<Path> for EntryWithDefId
[src]
type Error = WasmError
The type returned in the event of a conversion error.
fn try_from(t: Path) -> Result<Self, Self::Error>
[src]
impl TryFrom<SerializedBytes> for Path
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(sb: SerializedBytes) -> Result<Path, SerializedBytesError>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,