#[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§
Source§impl<S: SharedRef> Nested<S>
impl<S: SharedRef> Nested<S>
Sourcepub fn get<T: ReadTxn>(&self, txn: &T) -> Option<S>
pub fn get<T: ReadTxn>(&self, txn: &T) -> Option<S>
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§
Source§impl<S: Ord> Ord for Nested<S>
impl<S: Ord> Ord for Nested<S>
Source§impl<S: PartialOrd> PartialOrd for Nested<S>
impl<S: PartialOrd> PartialOrd for Nested<S>
impl<S: Eq> Eq for Nested<S>
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