[][src]Struct udp_netmsg::NetMessenger

pub struct NetMessenger { /* fields omitted */ }

This is the struct that the user will use for sending and receiving datagrams

Methods

impl NetMessenger[src]

pub fn new(
    source_ip: String,
    dest_ip: String,
    recv_buffer_size_bytes: u16
) -> NetMessenger
[src]

Simple Constructor for the class

pub fn recv(
    &mut self,
    blocking: bool,
    ignore_payload_len: bool
) -> Option<Box<dyn Datagram>>
[src]

Checks to see if a datagram has been received. Returns None if it has not. If data has been received, it removes the header_id and gets the constructor for the matched datagram struct. If 'ignore_payload_len' = true, it won't pass payload len (u32) to the datagram constructor passes remaining buffer to specific datagram constructor and returns struct

pub fn send<T: Datagram>(
    &self,
    datagram: Box<T>,
    include_payload_len: bool
) -> Result<(), String>
[src]

Takes in a struct that implements the datagram trait. Will call the to_buffer method and If 'include_header' = true: attach the header to the front and send the datagram If 'include_payload_len' = true: insert payload len (4 bytes) between header & payload Incorrectly setting include_payload_len will produce no error but bad data!

pub fn register(
    &mut self,
    key: u32,
    con: fn(_: Cursor<Vec<u8>>) -> Box<dyn Datagram>
)
[src]

Must register the header_id with the appropriate constructor. To easily get the header id, use STRUCT_NAME::id(). To easily get the constructor, use STRUCT_NAME::from_buffer Don't include the parentheses! We are passing in the function, not calling it!

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]