pub struct Strand(/* private fields */);Expand description
A Strand represents the metadata for the chain of Tixels
A Strand is verified for integrity and authenticity via the CID and public key it contains.
The most common way to obtain a Strand will be from a crate::twine::Twine,
a crate::resolver::Resolver, or using Strand::from_tagged_dag_json
or Strand::from_block.
A Strand contains an Arc to its underlying data, so it is efficient to clone and pass around.
§See also
Implementations§
Source§impl Strand
impl Strand
Sourcepub fn try_new<C>(container: C) -> Result<Self, VerificationError>where
C: TryInto<StrandSchemaVersion>,
VerificationError: From<<C as TryInto<StrandSchemaVersion>>::Error>,
pub fn try_new<C>(container: C) -> Result<Self, VerificationError>where
C: TryInto<StrandSchemaVersion>,
VerificationError: From<<C as TryInto<StrandSchemaVersion>>::Error>,
Create a new Strand from its underlying data
It is uncommon to use this directly.
Sourcepub fn details(&self) -> &Ipld
pub fn details(&self) -> &Ipld
Get the details of the Strand
Details describe the Strand in a human-readable way and can contain any data, usually described by the subspec.
Sourcepub fn extract_details<T: DeserializeOwned>(
&self,
) -> Result<T, VerificationError>
pub fn extract_details<T: DeserializeOwned>( &self, ) -> Result<T, VerificationError>
Deserialize the details as a specific type
Sourcepub fn verify_tixel(&self, tixel: &Tixel) -> Result<(), VerificationError>
pub fn verify_tixel(&self, tixel: &Tixel) -> Result<(), VerificationError>
Verify a Tixel using this Strand’s public key
Trait Implementations§
Source§impl From<Strand> for SingleQuery
impl From<Strand> for SingleQuery
Source§impl From<StrandResolution> for Strand
impl From<StrandResolution> for Strand
Source§fn from(resolution: StrandResolution) -> Self
fn from(resolution: StrandResolution) -> Self
Converts to this type from the input type.
Source§impl PartialEq<Strand> for StrandResolution
impl PartialEq<Strand> for StrandResolution
Source§impl PartialEq<StrandResolution> for Strand
impl PartialEq<StrandResolution> for Strand
Source§impl TwineBlock for Strand
impl TwineBlock for Strand
Source§fn from_tagged_dag_json<S: Display>(json: S) -> Result<Self, VerificationError>
fn from_tagged_dag_json<S: Display>(json: S) -> Result<Self, VerificationError>
Decode from DAG-JSON Read more
Source§fn from_bytes_unchecked(
hasher: Code,
bytes: Vec<u8>,
) -> Result<Self, VerificationError>
fn from_bytes_unchecked( hasher: Code, bytes: Vec<u8>, ) -> Result<Self, VerificationError>
Decode from raw bytes without checking CID
Source§fn from_block<T: AsRef<[u8]>>(
cid: Cid,
bytes: T,
) -> Result<Self, VerificationError>
fn from_block<T: AsRef<[u8]>>( cid: Cid, bytes: T, ) -> Result<Self, VerificationError>
Decode from a Block Read more
Source§fn tagged_dag_json(&self) -> String
fn tagged_dag_json(&self) -> String
Encode a
Tagged version to DAG-JSONSource§fn content_bytes(&self) -> Arc<[u8]>
fn content_bytes(&self) -> Arc<[u8]>
The serialized bytes of the content field
Source§fn tagged_dag_json_pretty(&self) -> String
fn tagged_dag_json_pretty(&self) -> String
Encode a
Tagged version to pretty dag-jsonSource§fn verify_cid(&self, expected: &Cid) -> Result<(), VerificationError>
fn verify_cid(&self, expected: &Cid) -> Result<(), VerificationError>
Verify the CID against the expected CID
Source§fn content_hash(&self) -> Multihash
fn content_hash(&self) -> Multihash
Get the hash of the content field
impl Eq for Strand
impl StructuralPartialEq for Strand
Auto Trait Implementations§
impl Freeze for Strand
impl RefUnwindSafe for Strand
impl Send for Strand
impl Sync for Strand
impl Unpin for Strand
impl UnwindSafe for Strand
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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