Struct Root
#[repr(transparent)]pub struct Root<S> {
pub name: Arc<str>,
/* private fields */
}Expand description
A logical reference to a root-level shared collection. It can be shared across different documents to reference the same logical type.
§Example
use yrs::{Doc, RootRef, SharedRef, TextRef, Transact};
let root = TextRef::root("hello");
let doc1 = Doc::new();
let txt1 = root.get_or_create(&mut doc1.transact_mut());
let doc2 = Doc::new();
let txt2 = root.get_or_create(&mut doc2.transact_mut());
// instances of TextRef point to different heap objects
assert_ne!(&txt1 as *const _, &txt2 as *const _);
// logical descriptors of both TextRef are the same as they refer to the
// same logical entity
assert_eq!(txt1.hook(), txt2.hook());Fields§
§name: Arc<str>Unique identifier of root-level shared collection.
Implementations§
§impl<S> Root<S>where
S: RootRef,
impl<S> Root<S>where
S: RootRef,
pub fn new<N>(name: N) -> Root<S>
pub fn new<N>(name: N) -> Root<S>
Creates a new logical reference for a root-level shared collection of a given name and type. Returned value can be used to resolve instances of root-level types by calling Root::get or Root::get_or_create.
pub fn get_or_create<T>(&self, txn: &mut T) -> Swhere
T: WriteTxn,
pub fn get_or_create<T>(&self, txn: &mut T) -> Swhere
T: WriteTxn,
Returns a reference to a shared root-level collection current Root represents, or creates it if it wasn’t instantiated before.
Trait Implementations§
§impl<S> Ord for Root<S>where
S: Ord,
impl<S> Ord for Root<S>where
S: Ord,
§impl<S> PartialOrd for Root<S>where
S: PartialOrd,
impl<S> PartialOrd for Root<S>where
S: PartialOrd,
impl<S> Eq for Root<S>where
S: Eq,
impl<S> StructuralPartialEq for Root<S>
Auto Trait Implementations§
impl<S> Freeze for Root<S>
impl<S> RefUnwindSafe for Root<S>where
S: RefUnwindSafe,
impl<S> Send for Root<S>where
S: Send,
impl<S> Sync for Root<S>where
S: Sync,
impl<S> Unpin for Root<S>where
S: Unpin,
impl<S> UnwindSafe for Root<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