pub struct ProtocolConnector<CP: ConnectedProtocol> {
pub buffer_size: usize,
/* private fields */
}
Expand description
ProtocolConnector contains the logic to use a ConnectedProtocol
to connect
to and forward messages to a protocol.
Fields§
§buffer_size: usize
The size of the mpsc::channel
to use when sending event objects from the main thread to the worker thread.
Implementations§
Source§impl<CP: ConnectedProtocol> ProtocolConnector<CP>
impl<CP: ConnectedProtocol> ProtocolConnector<CP>
Sourcepub fn new(protocol: CP) -> Self
pub fn new(protocol: CP) -> Self
Construct a ProtocolConnector with the default buffer_size
(10)
Sourcepub fn new_with_buffer_size(protocol: CP, buffer_size: usize) -> Self
pub fn new_with_buffer_size(protocol: CP, buffer_size: usize) -> Self
Construct a ProtocolConnector with a specified buffer_size
Sourcepub fn serve_and_log_errors(
self,
) -> (ProtocolSender<CP::Message>, impl Future<Output = ()>)
pub fn serve_and_log_errors( self, ) -> (ProtocolSender<CP::Message>, impl Future<Output = ()>)
serve_and_log_errors creates both a ProtocolSender and a future that can be used to send messages to the underlying protocol. All errors from the underlying protocol will be logged.
Sourcepub fn serve<ErrHandler: FnMut(ProtocolConnectorError<CP::ConnectError, CP::SendError>)>(
self,
h: ErrHandler,
) -> (ProtocolSender<CP::Message>, impl Future<Output = ()>)
pub fn serve<ErrHandler: FnMut(ProtocolConnectorError<CP::ConnectError, CP::SendError>)>( self, h: ErrHandler, ) -> (ProtocolSender<CP::Message>, impl Future<Output = ()>)
serve creates both a ProtocolSender and a future that can be used to send messages to the underlying protocol.
Auto Trait Implementations§
impl<CP> Freeze for ProtocolConnector<CP>where
CP: Freeze,
impl<CP> RefUnwindSafe for ProtocolConnector<CP>where
CP: RefUnwindSafe,
impl<CP> Send for ProtocolConnector<CP>where
CP: Send,
impl<CP> Sync for ProtocolConnector<CP>where
CP: Sync,
impl<CP> Unpin for ProtocolConnector<CP>where
CP: Unpin,
impl<CP> UnwindSafe for ProtocolConnector<CP>where
CP: UnwindSafe,
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