SocketConnection

Struct SocketConnection 

Source
pub struct SocketConnection<TInputMessage, TOutputMessage> { /* private fields */ }
Expand description

Represents an incoming socket connection. When a socket is connected, we retrieve an input stream, and need to respond with an output stream.

The socket is closed when the output stream is closed, or when the connection itself is dropped.

Implementations§

Source§

impl<TInputMessage, TOutputMessage> SocketConnection<TInputMessage, TOutputMessage>
where TInputMessage: 'static, TOutputMessage: 'static,

Source

pub fn new( context: &SceneContext, input: impl 'static + Send + Stream<Item = TInputMessage>, send_output: impl 'static + Send + FnOnce(&SceneContext, BoxStream<'static, TOutputMessage>), ) -> Self

Creates a new socket connection

Source

pub fn connect( self, output_stream: impl 'static + Send + Stream<Item = TOutputMessage>, ) -> BoxStream<'static, TInputMessage>

Sets the stream that will send the resulting output to the socket, and returns the input stream that can be used to read incoming data

Auto Trait Implementations§

§

impl<TInputMessage, TOutputMessage> Freeze for SocketConnection<TInputMessage, TOutputMessage>

§

impl<TInputMessage, TOutputMessage> !RefUnwindSafe for SocketConnection<TInputMessage, TOutputMessage>

§

impl<TInputMessage, TOutputMessage> Send for SocketConnection<TInputMessage, TOutputMessage>

§

impl<TInputMessage, TOutputMessage> !Sync for SocketConnection<TInputMessage, TOutputMessage>

§

impl<TInputMessage, TOutputMessage> Unpin for SocketConnection<TInputMessage, TOutputMessage>

§

impl<TInputMessage, TOutputMessage> !UnwindSafe for SocketConnection<TInputMessage, TOutputMessage>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.