Struct Nested
#[repr(transparent)]pub struct Nested<S> {
pub id: ID,
/* private fields */
}Expand description
A logical reference used to represent a shared collection nested within another one. Unlike Root-level types which cannot be deleted and exist eternally, Nested collections can be added (therefore don’t exist prior their instantiation) and deleted (so that any SharedRef values referencing them become unsafe and can point to objects that no longer exists!).
Use Nested::get in order to materialize current nested logical reference into shared ref type.
§Example
use yrs::{Doc, Map, Nested, SharedRef, TextPrelim, TextRef, Transact, WriteTxn};
let doc = Doc::new();
let mut txn = doc.transact_mut();
let root = txn.get_or_insert_map("root"); // root-level collection
let text = root.insert(&mut txn, "nested", TextPrelim::new("")); // nested collection
// convert nested TextRef into logical pointer
let nested: Nested<TextRef> = text.hook().into_nested().unwrap();
// logical reference can be used to retrieve accessible TextRef when its alive
assert_eq!(nested.get(&txn), Some(text));
// delete nested collection
root.remove(&mut txn, "nested");
// logical reference cannot resolve shared collections that have been deleted already
assert_eq!(nested.get(&txn), None);Fields§
§id: IDImplementations§
§impl<S> Nested<S>where
S: SharedRef,
impl<S> Nested<S>where
S: SharedRef,
pub fn get<T>(&self, txn: &T) -> Option<S>where
T: ReadTxn,
pub fn get<T>(&self, txn: &T) -> Option<S>where
T: ReadTxn,
If current Nested logical reference points to an instantiated and not-deleted shared
collection, a reference to that collection will be returned.
If the referenced collection has been deleted or was not yet present in current transaction
scope i.e. due to missing update, a None will be returned.
Trait Implementations§
§impl<S> Ord for Nested<S>where
S: Ord,
impl<S> Ord for Nested<S>where
S: Ord,
§impl<S> PartialOrd for Nested<S>where
S: PartialOrd,
impl<S> PartialOrd for Nested<S>where
S: PartialOrd,
impl<S> Eq for Nested<S>where
S: Eq,
impl<S> StructuralPartialEq for Nested<S>
Auto Trait Implementations§
impl<S> Freeze for Nested<S>
impl<S> RefUnwindSafe for Nested<S>where
S: RefUnwindSafe,
impl<S> Send for Nested<S>where
S: Send,
impl<S> Sync for Nested<S>where
S: Sync,
impl<S> Unpin for Nested<S>where
S: Unpin,
impl<S> UnwindSafe for Nested<S>where
S: 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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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