pub struct SyncService { /* private fields */ }Implementations§
Source§impl SyncService
impl SyncService
pub fn new( yrs_manager: Arc<YrsManager>, ws_server: Arc<WebSocketServer>, ) -> Self
Sourcepub fn init_room_from_tree(&self, room_id: &str, _tree: &Tree) -> Result<()>
pub fn init_room_from_tree(&self, room_id: &str, _tree: &Tree) -> Result<()>
将 ModuForge 的 Tree 初始化为房间快照
Sourcepub fn get_room_snapshot(&self, room_id: &str, tree: &Tree) -> RoomSnapshot
pub fn get_room_snapshot(&self, room_id: &str, tree: &Tree) -> RoomSnapshot
获取房间的完整快照(用于前端首次加载)
Sourcepub async fn handle_transaction_applied(
&self,
room_id: &str,
transactions: &[Transaction],
_new_state: &State,
client_id: Option<String>,
) -> Result<()>
pub async fn handle_transaction_applied( &self, room_id: &str, transactions: &[Transaction], _new_state: &State, client_id: Option<String>, ) -> Result<()>
🚀 内部方法:处理事务变更并以二进制格式批量推送到前端
Sourcepub fn remove_room(&self, room_id: &str)
pub fn remove_room(&self, room_id: &str)
移除房间
Sourcepub fn get_status(&self) -> SyncServiceStatus
pub fn get_status(&self) -> SyncServiceStatus
获取服务状态
Sourcepub fn yrs_manager(&self) -> &Arc<YrsManager>
pub fn yrs_manager(&self) -> &Arc<YrsManager>
获取 YrsManager 的引用(用于高级操作)
Sourcepub fn ws_server(&self) -> &Arc<WebSocketServer>
pub fn ws_server(&self) -> &Arc<WebSocketServer>
获取 WebSocketServer 的引用(用于高级操作)
Sourcepub fn broadcast_message_to_room(
&self,
room_id: &str,
message: String,
) -> Result<()>
pub fn broadcast_message_to_room( &self, room_id: &str, message: String, ) -> Result<()>
🚀 主动推送消息到房间的所有客户端
Sourcepub fn broadcast_data_to_room(&self, room_id: &str, data: Vec<u8>) -> Result<()>
pub fn broadcast_data_to_room(&self, room_id: &str, data: Vec<u8>) -> Result<()>
🚀 主动推送二进制数据到房间的所有客户端
Sourcepub fn send_message_to_client(
&self,
client_id: &str,
message: String,
) -> Result<()>
pub fn send_message_to_client( &self, client_id: &str, message: String, ) -> Result<()>
🚀 主动推送消息到特定客户端
Sourcepub fn send_data_to_client(&self, client_id: &str, data: Vec<u8>) -> Result<()>
pub fn send_data_to_client(&self, client_id: &str, data: Vec<u8>) -> Result<()>
🚀 主动推送二进制数据到特定客户端
Sourcepub fn notify_room_change(
&self,
room_id: &str,
change_description: String,
) -> Result<()>
pub fn notify_room_change( &self, room_id: &str, change_description: String, ) -> Result<()>
🚀 主动推送 ModuForge 变更通知到房间
Trait Implementations§
Source§impl Clone for SyncService
impl Clone for SyncService
Source§fn clone(&self) -> SyncService
fn clone(&self) -> SyncService
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SyncService
impl Debug for SyncService
Auto Trait Implementations§
impl Freeze for SyncService
impl !RefUnwindSafe for SyncService
impl Send for SyncService
impl Sync for SyncService
impl Unpin for SyncService
impl !UnwindSafe for SyncService
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,
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