#[repr(transparent)]pub struct Link<T>where
T: Clone,{
pub cid: Cid,
/* private fields */
}Expand description
A Link is a Cid with a type attached. The type represents the data that the Cid refers to. This is a helpful construct to use to ensure that data structures whose fields or elements may be Cids can still retain strong typing. A Link transparently represents its inner Cid, so a data structure that uses Links can safely be interpretted in terms of Cids, and vice-versa.
Fields§
§cid: CidImplementations§
Methods from Deref<Target = Cid>§
Sourcepub fn write_bytes<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
pub fn write_bytes<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
Writes the bytes to a byte stream, returns the number of bytes written.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the length in bytes needed to encode this cid into bytes.
Sourcepub fn to_string_of_base(&self, base: Base) -> Result<String, Error>
pub fn to_string_of_base(&self, base: Base) -> Result<String, Error>
Convert CID into a multibase encoded string
§Example
use cid::Cid;
use multibase::Base;
use multihash::{Code, MultihashDigest};
const RAW: u64 = 0x55;
let cid = Cid::new_v1(RAW, Code::Sha2_256.digest(b"foo"));
let encoded = cid.to_string_of_base(Base::Base64).unwrap();
assert_eq!(encoded, "mAVUSICwmtGto/8aP+ZtFPB0wQTQTQi1wZIO/oPmKXohiZueu");Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Link<T>where
T: Clone,
impl<'de, T> Deserialize<'de> for Link<T>where
T: Clone,
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Ord for Link<T>
impl<T> Ord for Link<T>
Source§impl<T> PartialOrd for Link<T>where
T: Clone + PartialOrd,
impl<T> PartialOrd for Link<T>where
T: Clone + PartialOrd,
Source§impl<T> TryBundle for Link<T>
impl<T> TryBundle for Link<T>
fn extend_bundle<'life0, 'life1, 'life2, 'async_trait, S>(
&'life0 self,
bundle: &'life1 mut Bundle,
store: &'life2 S,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
S: 'async_trait + BlockStore,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn extend_bundle_with_cid<'life0, 'life1, 'life2, 'async_trait, S>(
cid: &'life0 Cid,
bundle: &'life1 mut Bundle,
store: &'life2 S,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
S: 'async_trait + BlockStore,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn bundle<'life0, 'life1, 'async_trait, S>(
&'life0 self,
store: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Bundle>> + Send + 'async_trait>>where
S: 'async_trait + BlockStore,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn bundle_with_cid<'life0, 'life1, 'async_trait, S>(
cid: &'life0 Cid,
store: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Bundle>> + Send + 'async_trait>>where
S: 'async_trait + BlockStore,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
impl<T> Copy for Link<T>where
T: Clone,
impl<T> Eq for Link<T>where
T: Clone,
Auto Trait Implementations§
impl<T> Freeze for Link<T>
impl<T> RefUnwindSafe for Link<T>where
T: RefUnwindSafe,
impl<T> Send for Link<T>where
T: Send,
impl<T> Sync for Link<T>where
T: Sync,
impl<T> Unpin for Link<T>where
T: Unpin,
impl<T> UnwindSafe for Link<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> Base64Encode for Twhere
T: DagJson,
impl<T> Base64Encode for Twhere
T: DagJson,
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> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> DagJson for Twhere
T: Serialize + DeserializeOwned,
impl<T> DagJson for Twhere
T: Serialize + DeserializeOwned,
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.