pub struct Entry {
pub sig: SigInfo,
/* private fields */
}Fields§
§sig: SigInfoAuthentication information for this entry
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn builder(root: impl Into<ID>) -> EntryBuilder
pub fn builder(root: impl Into<ID>) -> EntryBuilder
Creates a new EntryBuilder for an entry associated with a specific tree root.
This is a convenience method and preferred over calling EntryBuilder::new() directly.
§Arguments
root- TheIDof the rootEntryof the tree this entry will belong to.
Sourcepub fn root_builder() -> EntryBuilder
pub fn root_builder() -> EntryBuilder
Creates a new EntryBuilder for a top-level (root) entry for a new tree.
This is a convenience method and preferred over calling EntryBuilder::new_top_level() directly.
Root entries have an empty string as their root ID and include a special ROOT subtree marker.
This method is typically used when creating a new tree.
Sourcepub fn id(&self) -> ID
pub fn id(&self) -> ID
Get the content-addressable ID of the entry.
The ID is calculated on demand by hashing the serialized JSON representation of the entry. Because entries are immutable once created and their contents are deterministically serialized, this ensures that identical entries will always have the same ID.
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Check if this entry is a root entry (contains the ROOT marker and has no parents).
Root entries are the top-level entries in the database and are distinguished by:
- Containing a subtree with the ROOT marker
- Having no parent entries (they are true tree roots)
This ensures that root entries are actual starting points of trees in the DAG.
Sourcepub fn in_subtree(&self, subtree_name: impl AsRef<str>) -> bool
pub fn in_subtree(&self, subtree_name: impl AsRef<str>) -> bool
Check if this entry contains data for a specific named subtree.
Sourcepub fn in_tree(&self, tree_id: impl AsRef<str>) -> bool
pub fn in_tree(&self, tree_id: impl AsRef<str>) -> bool
Check if this entry belongs to a specific tree, identified by its root ID.
Sourcepub fn subtrees(&self) -> Vec<String>
pub fn subtrees(&self) -> Vec<String>
Get the names of all subtrees this entry contains data for. The names are returned in alphabetical order.
Sourcepub fn metadata(&self) -> Option<&RawData>
pub fn metadata(&self) -> Option<&RawData>
Get the metadata associated with this entry’s tree node.
Metadata is optional information attached to an entry that is not part of the main data model and is not merged between entries.
Sourcepub fn data(&self, subtree_name: impl AsRef<str>) -> Result<&RawData>
pub fn data(&self, subtree_name: impl AsRef<str>) -> Result<&RawData>
Get the RawData for a specific named subtree within this entry.
Returns an error if the subtree is not found or if the subtree exists but has no data (None).
Sourcepub fn parents(&self) -> Result<Vec<ID>>
pub fn parents(&self) -> Result<Vec<ID>>
Get the IDs of the parent entries in the main tree history. The parent IDs are returned in alphabetical order.
Sourcepub fn subtree_parents(&self, subtree_name: impl AsRef<str>) -> Result<Vec<ID>>
pub fn subtree_parents(&self, subtree_name: impl AsRef<str>) -> Result<Vec<ID>>
Get the IDs of the parent entries specific to a named subtree’s history. The parent IDs are returned in alphabetical order.
Sourcepub fn subtree_height(&self, subtree_name: impl AsRef<str>) -> Result<u64>
pub fn subtree_height(&self, subtree_name: impl AsRef<str>) -> Result<u64>
Get the height of this entry in a specific subtree’s DAG.
If the subtree has an explicit height (Some(h)), that value is returned.
If the subtree height is None, it inherits from the main tree height.
This allows subtrees to either track independent heights (for subtrees with their own height strategy) or share the tree’s height (default).
Sourcepub fn canonical_for_signing(&self) -> Self
pub fn canonical_for_signing(&self) -> Self
Create a canonical representation of this entry for signing purposes.
This creates a copy of the entry with the signature field removed from auth, which is necessary for signature generation and verification. The returned entry has deterministic field ordering for consistent signatures.
Sourcepub fn canonical_bytes(&self) -> Result<Vec<u8>>
pub fn canonical_bytes(&self) -> Result<Vec<u8>>
Create canonical bytes for signing or ID generation.
This method serializes the entry to JSON with deterministic field ordering.
For signing purposes, call canonical_for_signing() first.
Sourcepub fn signing_bytes(&self) -> Result<Vec<u8>>
pub fn signing_bytes(&self) -> Result<Vec<u8>>
Create canonical bytes for signing (convenience method).
This combines canonical_for_signing() and canonical_bytes() for convenience.
pub fn validate(&self) -> Result<()>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
Source§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>,
impl Eq for Entry
impl StructuralPartialEq for Entry
Auto Trait Implementations§
impl Freeze for Entry
impl RefUnwindSafe for Entry
impl Send for Entry
impl Sync for Entry
impl Unpin for Entry
impl UnwindSafe for Entry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more