pub struct Connection<Sink, Stream> { /* private fields */ }Expand description
Connection handler over a pair of message streams, which implements a Yjs/Yrs awareness and update exchange protocol.
This connection implements Future pattern and can be awaited upon in order for a caller to recognize whether underlying websocket connection has been finished gracefully or abruptly.
Implementations§
Source§impl<Sink, Stream, E> Connection<Sink, Stream>
impl<Sink, Stream, E> Connection<Sink, Stream>
Source§impl<Sink, Stream, E> Connection<Sink, Stream>
impl<Sink, Stream, E> Connection<Sink, Stream>
Sourcepub fn new(
awareness: Arc<RwLock<Awareness>>,
sink: Sink,
stream: Stream,
) -> Self
pub fn new( awareness: Arc<RwLock<Awareness>>, sink: Sink, stream: Stream, ) -> Self
Wraps incoming [WebSocket] connection and supplied Awareness accessor into a new connection handler capable of exchanging Yrs/Yjs messages.
While creation of new [AxumConn] always succeeds, a connection itself can possibly fail while processing incoming input/output. This can be detected by awaiting for returned [AxumConn] and handling the awaited result.
Sourcepub fn awareness(&self) -> &Arc<RwLock<Awareness>>
pub fn awareness(&self) -> &Arc<RwLock<Awareness>>
Returns an underlying Awareness structure, that contains client state of that connection.
Sourcepub fn with_protocol<P>(
awareness: Arc<RwLock<Awareness>>,
sink: Sink,
stream: Stream,
protocol: P,
) -> Self
pub fn with_protocol<P>( awareness: Arc<RwLock<Awareness>>, sink: Sink, stream: Stream, protocol: P, ) -> Self
Wraps incoming [WebSocket] connection and supplied Awareness accessor into a new connection handler capable of exchanging Yrs/Yjs messages.
While creation of new [AxumConn] always succeeds, a connection itself can possibly fail while processing incoming input/output. This can be detected by awaiting for returned [AxumConn] and handling the awaited result.
Trait Implementations§
Source§impl<Sink, Stream> Future for Connection<Sink, Stream>
impl<Sink, Stream> Future for Connection<Sink, Stream>
impl<Sink, Stream> Unpin for Connection<Sink, Stream>
Auto Trait Implementations§
impl<Sink, Stream> Freeze for Connection<Sink, Stream>
impl<Sink, Stream> !RefUnwindSafe for Connection<Sink, Stream>
impl<Sink, Stream> Send for Connection<Sink, Stream>
impl<Sink, Stream> Sync for Connection<Sink, Stream>
impl<Sink, Stream> !UnwindSafe for Connection<Sink, Stream>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.