Struct rudp::Endpoint [−][src]
pub struct Endpoint<U: UdpLike> { /* fields omitted */ }
Stateful wrapper around a Udp-like object (facilitating sending of datagrams).
Allows communication with another Endpoint object.
The Endpoint does not have its own thread of control. Communication
is maintained by regular maintain
calls that perform heartbeats, resend lost
packets etc.
Methods
impl<U> Endpoint<U> where
U: UdpLike,
[src]
impl<U> Endpoint<U> where
U: UdpLike,
pub fn maintain(&mut self) -> Result<()>
[src]
pub fn maintain(&mut self) -> Result<()>
Discard acknowledged outputs, resend lost outputs and send a heartbeat if necessary.
ⓘImportant traits for Endpoint<U>pub fn new_with_config(socket: U, config: EndpointConfig) -> Endpoint<U>
[src]
pub fn new_with_config(socket: U, config: EndpointConfig) -> Endpoint<U>
Create a new Endpoint around the given Udp-like object, with the given configuration.
ⓘImportant traits for Endpoint<U>pub fn new(socket: U) -> Endpoint<U>
[src]
pub fn new(socket: U) -> Endpoint<U>
Create a new Endpoint around the given Udp-like object, with the default configuration.
pub fn recv(&mut self) -> Result<Option<&mut [u8]>>
[src]
pub fn recv(&mut self) -> Result<Option<&mut [u8]>>
Attempt to yield a message from the peer Endpoint that is ready for receipt. May block only if the wrapped Udp-like object may block. recv() calls may not call the inner receive, depending on the contents of the inbox.
Fatal errors return Err(_)
Reads that fail because they would block return Ok(None)
Successful reads return Ok(Some(x))
, where x is an in-place slice into the internal
buffer; thus, you need to drop the slice before interacting with the
Endpoint again.
pub fn as_set<F, R>(&mut self, work: F) -> R where
F: Sized + FnOnce(SetSender<U>) -> R,
R: Sized,
[src]
pub fn as_set<F, R>(&mut self, work: F) -> R where
F: Sized + FnOnce(SetSender<U>) -> R,
R: Sized,
Convenience function that passes a new SetSender
into the given closure.
See new_set
for more information.
ⓘImportant traits for SetSender<'a, U>pub fn new_set(&mut self) -> SetSender<U>
[src]
pub fn new_set(&mut self) -> SetSender<U>
The Endpoint
itself implements Sender
, allowing it to send messages.
new_set
returns a SetSender
object, which implements the same trait.
All messages sent by this setsender object have the added semantics of
relaxed ordering between them.
Trait Implementations
impl<U: Debug + UdpLike> Debug for Endpoint<U>
[src]
impl<U: Debug + UdpLike> Debug for Endpoint<U>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<U> Sender for Endpoint<U> where
U: UdpLike,
[src]
impl<U> Sender for Endpoint<U> where
U: UdpLike,
fn send_written(&mut self, guarantee: Guarantee) -> Result<usize>
[src]
fn send_written(&mut self, guarantee: Guarantee) -> Result<usize>
fn clear_written(&mut self)
[src]
fn clear_written(&mut self)
fn write_send(&mut self, data: &[u8], g: Guarantee) -> Result<(usize, usize)>
[src]
fn write_send(&mut self, data: &[u8], g: Guarantee) -> Result<(usize, usize)>
fn send_payload(&mut self, data: &[u8], g: Guarantee) -> Result<usize>
[src]
fn send_payload(&mut self, data: &[u8], g: Guarantee) -> Result<usize>
impl<U> Write for Endpoint<U> where
U: UdpLike,
[src]
impl<U> Write for Endpoint<U> where
U: UdpLike,
fn write(&mut self, bytes: &[u8]) -> Result<usize>
[src]
fn write(&mut self, bytes: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more