pub struct PacketWriter<'a> {
pub buf: &'a mut Vec<u8>,
pub threshold: CompressionThreshold,
}Expand description
An implementor of WritePacket backed by a Vec mutable reference.
Packets are written by appending to the contained vec. If an error occurs while writing, the written bytes are truncated away.
Fields§
§buf: &'a mut Vec<u8>§threshold: CompressionThresholdImplementations§
Source§impl<'a> PacketWriter<'a>
impl<'a> PacketWriter<'a>
pub fn new(buf: &'a mut Vec<u8>, threshold: CompressionThreshold) -> Self
Trait Implementations§
Source§impl<'a> Debug for PacketWriter<'a>
impl<'a> Debug for PacketWriter<'a>
Source§impl WritePacket for PacketWriter<'_>
impl WritePacket for PacketWriter<'_>
Source§fn write_packet_fallible<P>(&mut self, pkt: &P) -> Result<()>where
P: Packet + Encode,
fn write_packet_fallible<P>(&mut self, pkt: &P) -> Result<()>where
P: Packet + Encode,
Writes a packet to this object. The result of encoding the packet is
returned.
Source§fn write_packet_bytes(&mut self, bytes: &[u8])
fn write_packet_bytes(&mut self, bytes: &[u8])
Copies raw packet data directly into this object. Don’t use this unless
you know what you’re doing.
Source§fn write_packet<P>(&mut self, packet: &P)where
P: Packet + Encode,
fn write_packet<P>(&mut self, packet: &P)where
P: Packet + Encode,
Writes a packet to this object. Encoding errors are typically logged and
discarded.
Auto Trait Implementations§
impl<'a> Freeze for PacketWriter<'a>
impl<'a> RefUnwindSafe for PacketWriter<'a>
impl<'a> Send for PacketWriter<'a>
impl<'a> Sync for PacketWriter<'a>
impl<'a> Unpin for PacketWriter<'a>
impl<'a> !UnwindSafe for PacketWriter<'a>
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.