Struct MySyncFramed

Source
pub struct MySyncFramed<T> { /* private fields */ }
Expand description

Synchronous framed stream for MySql protocol.

This type is a synchronous alternative to tokio_codec::Framed.

Implementations§

Source§

impl<T> MySyncFramed<T>

Source

pub fn new(stream: T) -> Self

Creates new instance with the given stream.

Source

pub fn get_ref(&self) -> &T

Returns reference to a stream.

Source

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

Returns mutable reference to a stream.

Source

pub fn codec(&self) -> &PacketCodec

Returns reference to a codec.

Source

pub fn codec_mut(&mut self) -> &mut PacketCodec

Returns mutable reference to a codec.

Source

pub fn destruct(self) -> (BytesMut, BytesMut, PacketCodec, T)

Consumes self and returns wrapped buffers, codec and stream.

Source

pub fn construct( in_buf: BytesMut, out_buf: BytesMut, codec: PacketCodec, stream: T, ) -> Self

Creates new instance from given buffers, codec and stream.

Source§

impl<T> MySyncFramed<T>
where T: Write,

Source

pub fn write<U: Buf>(&mut self, item: &mut U) -> Result<(), PacketCodecError>

Will write packets into the stream. Stream may not be flushed.

Source

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

Will flush wrapped stream.

Source

pub fn send<U: Buf>(&mut self, item: &mut U) -> Result<(), PacketCodecError>

Will send packets into the stream. Stream will be flushed.

Source§

impl<T> MySyncFramed<T>
where T: Read,

Source

pub fn next_packet<U>(&mut self, dst: &mut U) -> Result<bool, PacketCodecError>
where U: AsRef<[u8]> + BufMut,

Returns true if dst contains the next packet.

false means, that the dst is empty and the stream is at eof.

Trait Implementations§

Source§

impl<T: Debug> Debug for MySyncFramed<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for MySyncFramed<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for MySyncFramed<T>
where T: RefUnwindSafe,

§

impl<T> Send for MySyncFramed<T>
where T: Send,

§

impl<T> Sync for MySyncFramed<T>
where T: Sync,

§

impl<T> Unpin for MySyncFramed<T>
where T: Unpin,

§

impl<T> UnwindSafe for MySyncFramed<T>
where T: UnwindSafe,

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> 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.