pub struct DocumentViewId(/* private fields */);Expand description
The identifier of a document view.
Contains the operation ids of the document graph tips, which is all the information we need to reliably reconstruct a specific version of a document.
Document view ids are considered equal if they contain the same set of operation ids, independent of their order. Serialised document view ids always contain sorted operation ids and deserialisation of a value will fail if this does not hold. This follows p2panda’s requirement that all serialised arrays must be sorted and leads to deterministic serialisation.
The document with the following operation graph has the id "2fa.." and six different document
view ids, meaning that this document can be represented in six versions:
1. ["2fa"]
2. ["de8"]
3. ["89c"]
4. ["eff"]
5. ["de8", "eff"]
6. ["89c", "eff"]
[CREATE] (Hash: "2fa..") <-- [UPDATE] (Hash: "de8..") <-- [UPDATE] (Hash: "89c..")
\
\__ [UPDATE] (Hash: "eff..")Implementations§
Source§impl DocumentViewId
impl DocumentViewId
Sourcepub fn new(graph_tips: &[OperationId]) -> Self
pub fn new(graph_tips: &[OperationId]) -> Self
Create a new document view id.
The given operation ids will automatically be sorted and de-duplicated.
Sourcepub fn graph_tips(&self) -> &[OperationId]
pub fn graph_tips(&self) -> &[OperationId]
Get the operation ids of this view id.
Sourcepub fn iter(&self) -> Iter<'_, OperationId>
pub fn iter(&self) -> Iter<'_, OperationId>
Get the operation ids of this view id.
Trait Implementations§
Source§impl Clone for DocumentViewId
impl Clone for DocumentViewId
Source§fn clone(&self) -> DocumentViewId
fn clone(&self) -> DocumentViewId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DocumentViewId
impl Debug for DocumentViewId
Source§impl<'de> Deserialize<'de> for DocumentViewId
impl<'de> Deserialize<'de> for DocumentViewId
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>,
Source§impl Display for DocumentViewId
impl Display for DocumentViewId
Source§impl From<&DocumentViewId> for DocumentViewHash
impl From<&DocumentViewId> for DocumentViewHash
Source§fn from(document_view_id: &DocumentViewId) -> Self
fn from(document_view_id: &DocumentViewId) -> Self
Source§impl From<DocumentViewId> for OperationValue
impl From<DocumentViewId> for OperationValue
Source§fn from(value: DocumentViewId) -> Self
fn from(value: DocumentViewId) -> Self
Source§impl From<DocumentViewId> for PlainValue
impl From<DocumentViewId> for PlainValue
Source§fn from(value: DocumentViewId) -> Self
fn from(value: DocumentViewId) -> Self
Source§impl From<DocumentViewId> for Vec<Hash>
impl From<DocumentViewId> for Vec<Hash>
Source§fn from(value: DocumentViewId) -> Self
fn from(value: DocumentViewId) -> Self
Source§impl From<Hash> for DocumentViewId
Convenience method converting a single hash into a document view id.
impl From<Hash> for DocumentViewId
Convenience method converting a single hash into a document view id.
Converts a Hash instance into a DocumentViewId, assuming that this document view only
consists of one graph tip hash.
Source§impl From<OperationId> for DocumentViewId
Convenience method converting a single OperationId into a document view id.
impl From<OperationId> for DocumentViewId
Convenience method converting a single OperationId into a document view id.
Converts an OperationId instance into a DocumentViewId, assuming that this document view
only consists of one graph tip hash.
Source§fn from(operation_id: OperationId) -> Self
fn from(operation_id: OperationId) -> Self
Source§impl FromStr for DocumentViewId
Convenience method converting a hash string into a document view id.
impl FromStr for DocumentViewId
Convenience method converting a hash string into a document view id.
Converts a string formatted document view id into a DocumentViewId. Expects multi-hash ids to
be hash strings separated by an _ character.
Source§impl Hash for DocumentViewId
impl Hash for DocumentViewId
Source§impl Human for DocumentViewId
impl Human for DocumentViewId
Source§impl Ord for DocumentViewId
impl Ord for DocumentViewId
Source§fn cmp(&self, other: &DocumentViewId) -> Ordering
fn cmp(&self, other: &DocumentViewId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DocumentViewId
impl PartialEq for DocumentViewId
Source§impl PartialOrd for DocumentViewId
impl PartialOrd for DocumentViewId
Source§impl Serialize for DocumentViewId
impl Serialize for DocumentViewId
Source§impl TryFrom<&[Hash]> for DocumentViewId
impl TryFrom<&[Hash]> for DocumentViewId
Source§impl TryFrom<&[String]> for DocumentViewId
impl TryFrom<&[String]> for DocumentViewId
Source§impl Validate for DocumentViewId
impl Validate for DocumentViewId
Source§fn validate(&self) -> Result<(), Self::Error>
fn validate(&self) -> Result<(), Self::Error>
Checks document view id against canonic format.
This verifies if the document view id is not empty and constituting operation ids are sorted, do not contain any duplicates and represent valid hashes (#OP3).
Source§type Error = DocumentViewIdError
type Error = DocumentViewIdError
impl Eq for DocumentViewId
impl StructuralPartialEq for DocumentViewId
Auto Trait Implementations§
impl Freeze for DocumentViewId
impl RefUnwindSafe for DocumentViewId
impl Send for DocumentViewId
impl Sync for DocumentViewId
impl Unpin for DocumentViewId
impl UnwindSafe for DocumentViewId
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,
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