#[non_exhaustive]pub enum CoReference<T> {
Weak(T),
}Expand description
Wrapps a reference/link/Cid and applies attributes useful in context of a Co.
- A
CoReferenceshould be encoded withcrate::KnownMultiCodec::CoReference. - A
CoReferenceshould be used with a narrow scope so that only the links to it are moved around. - A
CoReferenceshould be used for cross Co references to state and heads as this has special semantics for example encryption mapping.
§FAQ
§When to use CoReference::Weak and when [co_primitives::WeakCid]?
Use CoReference::Weak when you want to reference a root.
When the garbage collection reaches a CoReference::Weak it will not try to keep it alve with its parent.
Example: Keeping a historic root for reference or fast traversing.
Use [co_primitives::WeakCid] when the reference should not been handled as a link and will not be
accessed/traversed using this reference.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Weak(T)
Handle the reference as a weak reference. Used for reference counting.
Implementations§
Source§impl<T> CoReference<T>
impl<T> CoReference<T>
pub fn into_value(self) -> T
pub fn to_block(&self) -> Result<Block, BlockSerializerError>where
T: Serialize,
Trait Implementations§
Source§impl<T> AsRef<T> for CoReference<T>
impl<T> AsRef<T> for CoReference<T>
Source§impl<T: Clone> Clone for CoReference<T>
impl<T: Clone> Clone for CoReference<T>
Source§fn clone(&self) -> CoReference<T>
fn clone(&self) -> CoReference<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for CoReference<T>
impl<T: Debug> Debug for CoReference<T>
Source§impl<'de, T> Deserialize<'de> for CoReference<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for CoReference<T>where
T: Deserialize<'de>,
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: Hash> Hash for CoReference<T>
impl<T: Hash> Hash for CoReference<T>
Source§impl<T: Ord> Ord for CoReference<T>
impl<T: Ord> Ord for CoReference<T>
Source§fn cmp(&self, other: &CoReference<T>) -> Ordering
fn cmp(&self, other: &CoReference<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for CoReference<T>
impl<T: PartialEq> PartialEq for CoReference<T>
Source§impl<T: PartialOrd> PartialOrd for CoReference<T>
impl<T: PartialOrd> PartialOrd for CoReference<T>
Source§impl<T> Serialize for CoReference<T>where
T: Serialize,
impl<T> Serialize for CoReference<T>where
T: Serialize,
impl<T: Eq> Eq for CoReference<T>
impl<T> StructuralPartialEq for CoReference<T>
Auto Trait Implementations§
impl<T> Freeze for CoReference<T>where
T: Freeze,
impl<T> RefUnwindSafe for CoReference<T>where
T: RefUnwindSafe,
impl<T> Send for CoReference<T>where
T: Send,
impl<T> Sync for CoReference<T>where
T: Sync,
impl<T> Unpin for CoReference<T>where
T: Unpin,
impl<T> UnsafeUnpin for CoReference<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CoReference<T>where
T: UnwindSafe,
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<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