[−][src]Struct udp_netmsg::NetMessenger
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]
source_ip: String,
dest_ip: String,
recv_buffer_size_bytes: u16
) -> NetMessenger
Simple Constructor for the class
pub fn recv(
&mut self,
blocking: bool,
ignore_payload_len: bool
) -> Option<Box<dyn Datagram>>
[src]
&mut self,
blocking: bool,
ignore_payload_len: bool
) -> Option<Box<dyn Datagram>>
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]
&self,
datagram: Box<T>,
include_payload_len: bool
) -> Result<(), String>
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]
&mut self,
key: u32,
con: fn(_: Cursor<Vec<u8>>) -> Box<dyn Datagram>
)
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
impl Send for NetMessenger
impl Sync for NetMessenger
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Downcast for T where
T: Any,
[src]
T: Any,