Struct Kcp

Source
pub struct Kcp { /* private fields */ }

Implementations§

Source§

impl Kcp

Source

pub fn new(conv: u32) -> Self

Source

pub fn get_system_time(&self) -> u32

Source

pub fn initialize(&mut self)

§Warning

After initialization, self must be pinned in memory.

Source

pub fn peek(&mut self, buf: &mut [u8]) -> Result<usize>

io::ErrorKind::InvalidInput - buffer is too small to contain a frame.

Source

pub fn recv(&mut self, buf: &mut [u8]) -> Result<usize>

io::ErrorKind::InvalidInput - buffer is too small to contain a frame.

Source

pub fn recv_bytes(&mut self) -> Option<Bytes>

Source

pub fn peek_size(&self) -> usize

Source

pub fn send(&mut self, data: &[u8]) -> Result<usize>

io::ErrorKind::InvalidInput - frame is too large.

Source

pub fn input(&mut self, packet: &[u8]) -> Result<()>

ErrorKind::NotFound - conv is inconsistent

ErrorKind::InvalidData - Invalid packet or unrecognized command

Source

pub fn flush(&mut self)

Source

pub fn update(&mut self, current: u32)

Source

pub fn check(&self, current: u32) -> u32

Source

pub fn set_mtu(&mut self, mtu: u32) -> Result<()>

Source

pub fn set_nodelay( &mut self, nodelay: bool, interval: u32, resend: u32, nc: bool, )

Source

pub fn get_waitsnd(&self) -> u32

Source

pub fn set_wndsize(&mut self, sndwnd: u32, rcvwnd: u32)

Source§

impl Kcp

Source

pub fn conv(&self) -> u32

Source

pub fn current(&self) -> u32

Source

pub fn nsnd_que(&self) -> u32

Source

pub fn nrcv_que(&self) -> u32

Source

pub fn nrcv_buf(&self) -> u32

Source

pub fn duration_since(&self, since: u32) -> u32

Source

pub fn set_logmask(&mut self, logmask: u32)

Source

pub fn set_conv(&mut self, conv: u32)

Source

pub fn set_stream(&mut self, stream: bool)

Source

pub fn is_recv_queue_full(&self) -> bool

Source

pub fn is_send_queue_full(&self) -> bool

Source

pub fn has_ouput(&mut self) -> bool

Source

pub fn pop_output(&mut self) -> Option<BytesMut>

Source

pub fn write_ack_head( &self, buf: &mut BytesMut, cmd_flags: u8, payload_size: usize, )

Source

pub fn read_conv(buf: &[u8]) -> Option<u32>

Read conv from a packet buffer.

Source

pub fn read_cmd(buf: &[u8]) -> u8

Read cmd from a packet buffer.

Source

pub fn write_cmd(buf: &mut [u8], cmd: u8)

Write cmd to a packet buffer.

Source

pub fn read_payload_data(buf: &[u8]) -> Option<&[u8]>

Get the first segment payload from a packet buffer.

Source§

impl Kcp

Source

pub const SYN_CONV: u32 = 4_294_967_294u32

The conv used for SYN handshake.

Source

pub fn is_valid_conv(conv: u32) -> bool

Check if a conv is valid.

Source

pub fn rand_conv() -> u32

Generate a random conv.

Source

pub const fn max_frame_size(mtu: u32) -> u32

Maximum size of a data frame.

Trait Implementations§

Source§

impl Drop for Kcp

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Kcp

§

impl RefUnwindSafe for Kcp

§

impl Send for Kcp

§

impl Sync for Kcp

§

impl Unpin for Kcp

§

impl UnwindSafe for Kcp

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