pub struct Session<T: NetworkTransport> { /* private fields */ }Expand description
A collaborative session that manages documents and peers.
Implementations§
Source§impl<T: NetworkTransport> Session<T>
impl<T: NetworkTransport> Session<T>
Sourcepub fn new(
session_id: impl Into<String>,
local_peer_id: PeerId,
user_name: impl Into<String>,
transport: Arc<T>,
) -> Self
pub fn new( session_id: impl Into<String>, local_peer_id: PeerId, user_name: impl Into<String>, transport: Arc<T>, ) -> Self
Create a new session.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get the session ID.
Sourcepub fn local_peer_id(&self) -> &PeerId
pub fn local_peer_id(&self) -> &PeerId
Get the local peer ID.
Sourcepub fn subscribe(&self) -> Receiver<SessionEvent>
pub fn subscribe(&self) -> Receiver<SessionEvent>
Subscribe to session events.
Sourcepub async fn connect(&self) -> Result<(), SdkError>
pub async fn connect(&self) -> Result<(), SdkError>
Connect to the session (announce presence to peers).
Sourcepub async fn disconnect(&self) -> Result<(), SdkError>
pub async fn disconnect(&self) -> Result<(), SdkError>
Disconnect from the session.
Sourcepub fn open_text_doc(
&self,
document_id: impl Into<String>,
) -> Arc<RwLock<TextDoc>> ⓘ
pub fn open_text_doc( &self, document_id: impl Into<String>, ) -> Arc<RwLock<TextDoc>> ⓘ
Create or open a text document.
Sourcepub fn open_rich_text_doc(
&self,
document_id: impl Into<String>,
) -> Arc<RwLock<RichTextDoc>> ⓘ
pub fn open_rich_text_doc( &self, document_id: impl Into<String>, ) -> Arc<RwLock<RichTextDoc>> ⓘ
Create or open a rich text document.
Sourcepub fn open_json_doc(
&self,
document_id: impl Into<String>,
) -> Arc<RwLock<JsonDoc>> ⓘ
pub fn open_json_doc( &self, document_id: impl Into<String>, ) -> Arc<RwLock<JsonDoc>> ⓘ
Create or open a JSON document.
Sourcepub fn open_documents(&self) -> Vec<String>
pub fn open_documents(&self) -> Vec<String>
Get list of open document IDs.
Auto Trait Implementations§
impl<T> Freeze for Session<T>
impl<T> !RefUnwindSafe for Session<T>
impl<T> Send for Session<T>
impl<T> Sync for Session<T>
impl<T> Unpin for Session<T>
impl<T> !UnwindSafe for Session<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