Struct RawChannel

Source
pub struct RawChannel { /* private fields */ }
Expand description

Represents a raw channel between a manager client and server. Underneath, this routes incoming and outgoing data from a proxied server to an inmemory transport.

Implementations§

Source§

impl RawChannel

Source

pub fn abort(&self)

Source

pub fn into_client<T, U>(self) -> Client<T, U>
where T: Send + Sync + Serialize + 'static, U: Send + Sync + DeserializeOwned + 'static,

Consumes this channel, returning a typed client wrapping the transport.

§Note

This does not perform any additional handshakes or authentication. All authentication was performed during separate connection and this merely wraps an inmemory transport that maps to the primary connection.

Source

pub fn into_untyped_client(self) -> UntypedClient

Consumes this channel, returning an untyped client wrapping the transport.

§Note

This does not perform any additional handshakes or authentication. All authentication was performed during separate connection and this merely wraps an inmemory transport that maps to the primary connection.

Source

pub fn as_framed_transport(&self) -> &FramedTransport<InmemoryTransport>

Returns reference to the underlying framed transport.

Source

pub fn as_mut_framed_transport( &mut self, ) -> &mut FramedTransport<InmemoryTransport>

Returns mutable reference to the underlying framed transport.

Source

pub fn into_framed_transport(self) -> FramedTransport<InmemoryTransport>

Consumes the channel, returning the underlying framed transport.

Methods from Deref<Target = FramedTransport<InmemoryTransport>>§

Source

pub fn set_codec(&mut self, codec: BoxedCodec)

Replaces the current codec with the provided codec. Note that any bytes in the incoming or outgoing buffers will remain in the transport, meaning that this can cause corruption if the bytes in the buffers do not match the new codec.

For safety, use clear to wipe the buffers before further use.

Source

pub fn codec(&self) -> &dyn Codec

Returns a reference to the codec used by the transport.

§Note

Be careful when accessing the codec to avoid corrupting it through unexpected modifications as this will place the transport in an undefined state.

Source

pub fn mut_codec(&mut self) -> &mut dyn Codec

Returns a mutable reference to the codec used by the transport.

§Note

Be careful when accessing the codec to avoid corrupting it through unexpected modifications as this will place the transport in an undefined state.

Source

pub fn clear(&mut self)

Clears the internal transport buffers.

Source

pub fn as_inner(&self) -> &T

Returns a reference to the inner value this transport wraps.

Source

pub fn as_mut_inner(&mut self) -> &mut T

Returns a mutable reference to the inner value this transport wraps.

Source

pub async fn ready(&self, interest: Interest) -> Result<Ready>

Waits for the transport to be ready based on the given interest, returning the ready status

Source

pub async fn readable(&self) -> Result<()>

Waits for the transport to be readable to follow up with try_read_frame.

Source

pub async fn writeable(&self) -> Result<()>

Waits for the transport to be writeable to follow up with try_write_frame.

Source

pub async fn readable_or_writeable(&self) -> Result<Ready>

Waits for the transport to be readable or writeable, returning the Ready status.

Source

pub fn try_flush(&mut self) -> Result<usize>

Attempts to flush any remaining bytes in the outgoing queue, returning the total bytes written as a result of the flush. Note that a return of 0 bytes does not indicate that the underlying transport has closed, but rather that no bytes were flushed such as when the outgoing queue is empty.

This is accomplished by continually calling the inner transport’s try_write. If 0 is returned from a call to try_write, this will fail with [ErrorKind::WriteZero].

This call may return an error with ErrorKind::WouldBlock in the case that the transport is not ready to write data.

Source

pub async fn flush(&mut self) -> Result<()>

Flushes all buffered, outgoing bytes using repeated calls to try_flush.

Source

pub fn try_read_frame(&mut self) -> Result<Option<OwnedFrame>>

Reads a frame of bytes by using the Codec tied to this transport. Returns Ok(Some(frame)) upon reading a frame, or Ok(None) if the underlying transport has closed.

This call may return an error with ErrorKind::WouldBlock in the case that the transport is not ready to read data or has not received a full frame before waiting.

Source

pub fn try_read_frame_as<D: DeserializeOwned>(&mut self) -> Result<Option<D>>

Reads a frame using try_read_frame and then deserializes the bytes into D.

Source

pub async fn read_frame(&mut self) -> Result<Option<OwnedFrame>>

Continues to invoke try_read_frame until a frame is successfully read, an error is encountered that is not ErrorKind::WouldBlock, or the underlying transport has closed.

Source

pub async fn read_frame_as<D: DeserializeOwned>(&mut self) -> Result<Option<D>>

Reads a frame using read_frame and then deserializes the bytes into D.

Source

pub fn try_write_frame<'a, F>(&mut self, frame: F) -> Result<()>
where F: TryInto<Frame<'a>>, F::Error: Into<Box<dyn Error + Send + Sync>>,

Writes a frame of bytes by using the Codec tied to this transport.

This is accomplished by continually calling the inner transport’s try_write. If 0 is returned from a call to try_write, this will fail with ErrorKind::WriteZero.

This call may return an error with ErrorKind::WouldBlock in the case that the transport is not ready to write data or has not written the entire frame before waiting.

Source

pub fn try_write_frame_for<D: Serialize>(&mut self, value: &D) -> Result<()>

Serializes value into bytes and passes them to try_write_frame.

Source

pub async fn write_frame<'a, F>(&mut self, frame: F) -> Result<()>
where F: TryInto<Frame<'a>>, F::Error: Into<Box<dyn Error + Send + Sync>>,

Invokes try_write_frame followed by a continuous calls to try_flush until a frame is successfully written, an error is encountered that is not ErrorKind::WouldBlock, or the underlying transport has closed.

Source

pub async fn write_frame_for<D: Serialize>(&mut self, value: &D) -> Result<()>

Serializes value into bytes and passes them to write_frame.

Source

pub async fn do_frozen<F, X>(&mut self, f: F) -> Result<()>
where F: FnMut(&mut Self) -> X, X: Future<Output = Result<()>>,

Executes the async function while the Backup of this transport is frozen.

Source

pub async fn synchronize(&mut self) -> Result<()>

Places the transport in synchronize mode where it communicates with the other side how many frames have been sent and received. From there, any frames not received by the other side are sent again and then this transport waits for any missing frames that it did not receive from the other side.

§Note

This will clear the internal incoming and outgoing buffers, so any frame that was in transit in either direction will be dropped.

Source

pub async fn client_handshake(&mut self) -> Result<()>

Perform the client-side of a handshake. See handshake for more details.

Source

pub async fn server_handshake(&mut self) -> Result<()>

Perform the server-side of a handshake. See handshake for more details.

Source

pub async fn handshake(&mut self, handshake: Handshake) -> Result<()>

Performs a handshake in order to establish a new codec to use between this transport and the other side. The parameter handshake defines how the transport will handle the handshake with Client being used to pick the compression and encryption used while Server defines what the choices are for compression and encryption.

This will reset the framed transport’s codec to PlainCodec in order to communicate which compression and encryption to use. Upon selecting an encryption type, a shared secret key will be derived on both sides and used to establish the EncryptionCodec, which in combination with the CompressionCodec (if any) will replace this transport’s codec.

§Client
  1. Wait for options from server
  2. Send to server a compression and encryption choice
  3. Configure framed transport using selected choices
  4. Invoke on_handshake function
§Server
  1. Send options to client
  2. Receive choices from client
  3. Configure framed transport using client’s choices
  4. Invoke on_handshake function
§Failure

The handshake will fail in several cases:

  • If any frame during the handshake fails to be serialized
  • If any unexpected frame is received during the handshake
  • If using encryption and unable to derive a shared secret key

If a failure happens, the codec will be reset to what it was prior to the handshake request, and all internal buffers will be cleared to avoid corruption.

Source

pub async fn exchange_keys(&mut self) -> Result<SecretKey32>

Places the transport into key-exchange mode where it attempts to derive a shared secret key with the other transport.

Links the underlying transports together using InmemoryTransport::link.

Trait Implementations§

Source§

impl Deref for RawChannel

Source§

type Target = FramedTransport<InmemoryTransport>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for RawChannel

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes and produces Box<dyn Any>
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V