pub struct Utils;Expand description
获取当前时间戳(毫秒)
Implementations§
Source§impl Utils
impl Utils
pub fn get_unix_time() -> u64
Sourcepub fn apply_yrs_to_tree(doc: &Doc) -> ClientResult<Tree>
pub fn apply_yrs_to_tree(doc: &Doc) -> ClientResult<Tree>
将 Yrs 文档转换为 ModuForge Tree 这是从协作状态重建文档树的关键方法
Sourcepub async fn apply_tree_to_yrs(
awareness_ref: AwarenessRef,
tree: &Tree,
) -> ClientResult<()>
pub async fn apply_tree_to_yrs( awareness_ref: AwarenessRef, tree: &Tree, ) -> ClientResult<()>
初始化树 将树同步到 Yrs 文档
Sourcepub fn sync_tree_to_yrs(
tree: &Tree,
txn: &mut TransactionMut<'_>,
) -> ClientResult<()>
pub fn sync_tree_to_yrs( tree: &Tree, txn: &mut TransactionMut<'_>, ) -> ClientResult<()>
将树同步到 Yrs 文档
Sourcepub async fn apply_transaction_to_yrs(
awareness_ref: AwarenessRef,
transaction: &Transaction,
) -> ClientResult<()>
pub async fn apply_transaction_to_yrs( awareness_ref: AwarenessRef, transaction: &Transaction, ) -> ClientResult<()>
将事务应用到 Yrs 文档
Sourcepub async fn apply_transactions_to_yrs(
awareness_ref: AwarenessRef,
transactions: &[Transaction],
) -> ClientResult<()>
pub async fn apply_transactions_to_yrs( awareness_ref: AwarenessRef, transactions: &[Transaction], ) -> ClientResult<()>
将事务应用到 Yrs 文档
Sourcepub fn json_value_to_yrs_any(value: &JsonValue) -> Any
pub fn json_value_to_yrs_any(value: &JsonValue) -> Any
将 JSON 值转换为 Yrs 的 Any 类型
Sourcepub fn add_mark_to_array(
marks_array: &ArrayRef,
txn: &mut TransactionMut<'_>,
mark: &Mark,
)
pub fn add_mark_to_array( marks_array: &ArrayRef, txn: &mut TransactionMut<'_>, mark: &Mark, )
将标记添加到 Yrs 数组中
Sourcepub fn get_or_create_node_data_map(
nodes_map: &MapRef,
txn: &mut TransactionMut<'_>,
node_id: &str,
) -> MapRef
pub fn get_or_create_node_data_map( nodes_map: &MapRef, txn: &mut TransactionMut<'_>, node_id: &str, ) -> MapRef
获取或创建节点数据映射
Sourcepub fn get_or_create_node_attrs_map(
node_data_map: &MapRef,
txn: &mut TransactionMut<'_>,
) -> MapRef
pub fn get_or_create_node_attrs_map( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> MapRef
获取或创建节点属性映射
Sourcepub fn get_or_create_content_array(
node_data_map: &MapRef,
txn: &mut TransactionMut<'_>,
) -> ArrayRef
pub fn get_or_create_content_array( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> ArrayRef
获取或创建标记数组
Sourcepub fn yrs_any_to_json_value(value: &Any) -> Option<JsonValue>
pub fn yrs_any_to_json_value(value: &Any) -> Option<JsonValue>
将 Yrs 的 Any 类型转换为 JSON 值
Sourcepub fn get_or_create_marks_array(
node_data_map: &MapRef,
txn: &mut TransactionMut<'_>,
) -> ArrayRef
pub fn get_or_create_marks_array( node_data_map: &MapRef, txn: &mut TransactionMut<'_>, ) -> ArrayRef
获取或创建标记数组
Sourcepub fn get_root_id_from_yrs_doc(doc: &Doc) -> ClientResult<String>
pub fn get_root_id_from_yrs_doc(doc: &Doc) -> ClientResult<String>
从 Yrs 文档中获取根节点ID
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> 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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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