[][src]Struct udp_netmsg::manager::Builder

pub struct Builder { /* fields omitted */ }

Helper struct for configuring the UDP Manager.

Implementations

impl Builder[src]

pub fn init() -> Builder[src]

Initializer that sets default configuration values. These configurations may be changed via provided methods to meet the needs of the program.

pub fn buffer_len(self, len: usize) -> Builder[src]

Sets the buffer_len

The closer the this value is to the size of datagrams, the faster the execution. This is because less time is spent reallocating memory when the buffer size needs to be increased. To large of a buffer is also bad as you 1. waste space & 2. waste time allocating unecessary space.

Default value: 100 bytes

pub fn use_ids(self, use_ids: bool) -> Builder[src]

Determines if ids are appended to the datagram

Setting this to false means that sent and received datagrams will not have headers attached. Because of this, received datagrams will not be sorted according to header types.

It is suggested to use the peek and remove method in conjunction when setting ids to false. This is because using the get method will remove the object even if it fails to deserialize. Using the peek method allows you to attempt to deserialize the object multiple times. Once it has succeeded, you can then call the remove method to remove the object from the underyling storage.

Default value: True

pub fn read_timeout(self, read_timeout: Option<Duration>) -> Builder[src]

Used to determine how long the system should wait before returning from the try_recv method. A longer timeout value results in less cpu resources used, but a slower response from the method get method as they both need mutable access to the same resource. Setting this value to anything other then None also sets non_blocking to false as this value is only necessary when it is blocking.

Default value: None

pub fn non_blocking(self, non_blocking: bool) -> Builder[src]

Used to determine if the system will block the background thread until a message is received. Only set this to false if you are certain you will receive a message. Currently this shares mutable access needs of the same resource with the get method. If data is never received, the try_recv method will never relinquish control of the resource over to the get method.

Default value: False

pub fn socket(self, socket: String) -> Builder[src]

Sets the listening port to receive datagrams on.

Default value: 39507

pub fn start<T>(self) -> Result<UdpManager<T>, Error> where
    T: SerDesType
[src]

Creates and starts the UDP Manager

Uses the configurations set with the builder struct to initialize and start the UDP Manager. Specifies the SerDes format for data. Spins up the background thread that continiously checks for datagrams

Errors

Errors if configurations to the underlying UDP Socket fail or if it was unable to create the new thread at the OS level.

Auto Trait Implementations

impl RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl UnwindSafe for Builder

Blanket Implementations

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

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

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

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.