Strand

Struct Strand 

Source
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

Source

pub fn try_new<C>(container: C) -> Result<Self, VerificationError>

Create a new Strand from its underlying data

It is uncommon to use this directly.

Source

pub fn cid(&self) -> Cid

Get the CID of the Strand

Source

pub fn key(&self) -> PublicKey

Get the public key of the Strand

Source

pub fn radix(&self) -> u8

Get the radix value of the skiplist

Source

pub fn spec_str(&self) -> &str

Get the spec string of the Strand

Source

pub fn version(&self) -> Version

Get the twine version of this record

Source

pub fn subspec(&self) -> Option<Subspec>

Get the subspec of this record if it exists

Source

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.

Source

pub fn extract_details<T: DeserializeOwned>( &self, ) -> Result<T, VerificationError>

Deserialize the details as a specific type

Source

pub fn expiry(&self) -> Option<DateTime<Utc>>

Get the expiry date of the Strand

Source

pub fn verify_tixel(&self, tixel: &Tixel) -> Result<(), VerificationError>

Verify a Tixel using this Strand’s public key

Source

pub fn hasher(&self) -> Code

Get the hasher (Code) used to compute the CID

Trait Implementations§

Source§

impl AsCid for Strand

Source§

fn as_cid(&self) -> &Cid

Get the CID as a reference
Source§

impl Clone for Strand

Source§

fn clone(&self) -> Strand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Strand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Strand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Strand> for AnyTwine

Source§

fn from(s: Strand) -> Self

Converts to this type from the input type.
Source§

impl From<Strand> for Cid

Source§

fn from(t: Strand) -> Self

Converts to this type from the input type.
Source§

impl From<Strand> for SingleQuery

Source§

fn from(strand: Strand) -> Self

Converts to this type from the input type.
Source§

impl From<StrandResolution> for Strand

Source§

fn from(resolution: StrandResolution) -> Self

Converts to this type from the input type.
Source§

impl Hash for Strand

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<AnyTwine> for Strand

Source§

fn eq(&self, other: &AnyTwine) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Strand> for AnyTwine

Source§

fn eq(&self, other: &Strand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Strand> for StrandResolution

Source§

fn eq(&self, other: &Strand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<StrandResolution> for Strand

Source§

fn eq(&self, other: &StrandResolution) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Strand

Source§

fn eq(&self, other: &Strand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<AnyTwine> for Strand

Source§

type Error = VerificationError

The type returned in the event of a conversion error.
Source§

fn try_from(s: AnyTwine) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TwineBlock for Strand

Source§

fn cid(&self) -> &Cid

Get the CID
Source§

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>

Decode from raw bytes without checking CID
Source§

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

Encode a Tagged version to DAG-JSON
Source§

fn bytes(&self) -> Arc<[u8]>

Encode to raw bytes
Source§

fn content_bytes(&self) -> Arc<[u8]>

The serialized bytes of the content field
Source§

fn tagged_dag_json_pretty(&self) -> String

Encode a Tagged version to pretty dag-json
Source§

fn verify_cid(&self, expected: &Cid) -> Result<(), VerificationError>

Verify the CID against the expected CID
Source§

fn hasher(&self) -> Code

Get the hasher (Code) for this data structure
Source§

fn content_hash(&self) -> Multihash

Get the hash of the content field
Source§

impl Eq for Strand

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> References<RawCodec> for T

Source§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>
where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> BaseResolverBounds for T
where T: Send + Sync,

Source§

impl<T> MaybeSend for T
where T: Send,