pub struct Client<T: NetworkTransport> { /* private fields */ }Expand description
The main MDCS client for collaborative editing.
The client manages sessions, documents, and network connections.
§Example
use mdcs_sdk::{Client, ClientConfig};
// Create a client
let config = ClientConfig {
user_name: "Alice".to_string(),
..Default::default()
};
let client = Client::new_with_memory_transport(config);
// Create a session
let session = client.create_session("my-session");
// Open a document
let doc = session.open_text_doc("shared-doc");
doc.write().insert(0, "Hello, world!");Implementations§
Source§impl Client<MemoryTransport>
impl Client<MemoryTransport>
Sourcepub fn new_with_memory_transport(config: ClientConfig) -> Self
pub fn new_with_memory_transport(config: ClientConfig) -> Self
Create a new client with an in-memory transport (for testing).
Source§impl<T: NetworkTransport> Client<T>
impl<T: NetworkTransport> Client<T>
Sourcepub fn new(peer_id: PeerId, transport: Arc<T>, config: ClientConfig) -> Self
pub fn new(peer_id: PeerId, transport: Arc<T>, config: ClientConfig) -> Self
Create a new client with a custom transport.
Sourcepub fn create_session(&self, session_id: impl Into<String>) -> Arc<Session<T>>
pub fn create_session(&self, session_id: impl Into<String>) -> Arc<Session<T>>
Create a new collaborative session.
Sourcepub fn get_session(&self, session_id: &str) -> Option<Arc<Session<T>>>
pub fn get_session(&self, session_id: &str) -> Option<Arc<Session<T>>>
Get an existing session.
Sourcepub fn close_session(&self, session_id: &str)
pub fn close_session(&self, session_id: &str)
Close a session.
Sourcepub fn session_ids(&self) -> Vec<String>
pub fn session_ids(&self) -> Vec<String>
List all active session IDs.
Sourcepub async fn disconnect_peer(&self, peer_id: &PeerId) -> Result<(), SdkError>
pub async fn disconnect_peer(&self, peer_id: &PeerId) -> Result<(), SdkError>
Disconnect from a peer.
Sourcepub async fn connected_peers(&self) -> Vec<Peer>
pub async fn connected_peers(&self) -> Vec<Peer>
Get list of connected peers.
Auto Trait Implementations§
impl<T> Freeze for Client<T>
impl<T> !RefUnwindSafe for Client<T>
impl<T> Send for Client<T>
impl<T> Sync for Client<T>
impl<T> Unpin for Client<T>
impl<T> !UnwindSafe for Client<T>
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