Skip to main content

Utils

Struct Utils 

Source
pub struct Utils;
Expand description

获取当前时间戳(毫秒)

Implementations§

Source§

impl Utils

Source

pub fn get_unix_time() -> u64

Source

pub fn apply_yrs_to_tree(doc: &Doc) -> ClientResult<Tree>

将 Yrs 文档转换为 ModuForge Tree 这是从协作状态重建文档树的关键方法

Source

pub async fn apply_tree_to_yrs( awareness_ref: AwarenessRef, tree: &Tree, ) -> ClientResult<()>

初始化树 将树同步到 Yrs 文档

Source

pub fn sync_tree_to_yrs( tree: &Tree, txn: &mut TransactionMut<'_>, ) -> ClientResult<()>

将树同步到 Yrs 文档

Source

pub async fn apply_transaction_to_yrs( awareness_ref: AwarenessRef, transaction: &Transaction, ) -> ClientResult<()>

将事务应用到 Yrs 文档

Source

pub async fn apply_transactions_to_yrs( awareness_ref: AwarenessRef, transactions: &[Transaction], ) -> ClientResult<()>

将事务应用到 Yrs 文档

Source

pub fn json_value_to_yrs_any(value: &JsonValue) -> Any

将 JSON 值转换为 Yrs 的 Any 类型

Source

pub fn add_mark_to_array( marks_array: &ArrayRef, txn: &mut TransactionMut<'_>, mark: &Mark, )

将标记添加到 Yrs 数组中

Source

pub fn get_or_create_node_data_map( nodes_map: &MapRef, txn: &mut TransactionMut<'_>, node_id: &str, ) -> MapRef

获取或创建节点数据映射

Source

pub fn get_or_create_node_attrs_map( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> MapRef

获取或创建节点属性映射

Source

pub fn get_or_create_content_array( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> ArrayRef

获取或创建标记数组

Source

pub fn yrs_any_to_json_value(value: &Any) -> Option<JsonValue>

将 Yrs 的 Any 类型转换为 JSON 值

Source

pub fn get_or_create_marks_array( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> ArrayRef

获取或创建标记数组

Source

pub fn get_root_id_from_yrs_doc(doc: &Doc) -> ClientResult<String>

从 Yrs 文档中获取根节点ID

Source

pub fn build_tree_nodes_from_yrs( node_id: &str, nodes_map: &MapRef, txn: &Transaction<'_>, tree_nodes: &mut HashMap<NodeId, Arc<Node>>, parent_map: &mut HashMap<NodeId, NodeId>, parent_id: Option<&NodeId>, ) -> ClientResult<()>

从 Yrs 文档的 nodes_map 递归构建所有节点和 parent_map

Source

pub fn build_node_enum_from_map( node: &Node, tree_nodes: &HashMap<NodeId, Arc<Node>>, ) -> NodeTree

递归构建 NodeTree

Auto Trait Implementations§

§

impl Freeze for Utils

§

impl RefUnwindSafe for Utils

§

impl Send for Utils

§

impl Sync for Utils

§

impl Unpin for Utils

§

impl UnsafeUnpin for Utils

§

impl UnwindSafe for Utils

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more