[][src]Trait craftio_rs::CraftIo

pub trait CraftIo {
    pub fn set_state(&mut self, next: State);
pub fn set_compression_threshold(&mut self, threshold: Option<i32>);
pub fn enable_encryption(
        &mut self,
        key: &[u8],
        iv: &[u8]
    ) -> Result<(), CipherError>;
pub fn set_max_packet_size(&mut self, max_size: usize);
pub fn ensure_buf_capacity(&mut self, capacity: usize);
pub fn ensure_compression_buf_capacity(&mut self, capacity: usize); }

Trait for stateful connection types, such as the CraftReader<R> or CraftWriter<W> or combo type CraftConnection<R, W>.

Allows for control over protocol state, compression threshold, and encryption if those features are enabled.

Required methods

pub fn set_state(&mut self, next: State)[src]

Changes the current connection state. For readers, this changes how numeric packet IDs are interpreted. For writers, this will change the packets that can be written without a panic.

pub fn set_compression_threshold(&mut self, threshold: Option<i32>)[src]

Modifies the compression configuration. If a value of None is provided, then compression is disabled. If a value of Some is provided, then the threshold is set to that value.

If a 0 or negative value is provided in a Some variant, then it is the same as calling this function with the None variant

pub fn enable_encryption(
    &mut self,
    key: &[u8],
    iv: &[u8]
) -> Result<(), CipherError>
[src]

Modifies the encryption configuration. This function should only be called once, and can only be used to enable encryption.

If encryption is already enabled or the arguments are not valid for the cipher, then an error is returned and nothing in the underlying state is changed.

pub fn set_max_packet_size(&mut self, max_size: usize)[src]

Sets the max packet size which this I/O wrapper will decode or transmit.

This limit is meant to be used to ensure connections never allocate gigantic buffers. Therefore, the limitation applies to the representation of packet in memory. This means that a reader cannot read a compressed packet above this threshold, nor can it decompress to a packet which is above this threshold. A writer cannot write a packet which exceeds this size (when serialized) even if compression is enabled.

todo split the compressed vs not compressed limits?

pub fn ensure_buf_capacity(&mut self, capacity: usize)[src]

pub fn ensure_compression_buf_capacity(&mut self, capacity: usize)[src]

Loading content...

Implementors

impl<R> CraftIo for CraftReader<R>[src]

impl<R, W> CraftIo for CraftConnection<R, W>[src]

impl<W> CraftIo for CraftWriter<W>[src]

Loading content...