Struct libutp_rs::UtpContext [−][src]
A UTP context
The UtpContext
is the core of a UTP application. It sets up the backing UDP socket and provides
methods for initiating and accepting connections.
Implementations
impl UtpContext
[src]
pub fn bind(addr: SocketAddr) -> Result<UtpContext>
[src]
Creates the backing UDP socket and returns a new UtpContext
Example
use libutp_rs::UtpContext; let ctx = UtpContext::bind("127.0.0.1:5000".parse().unwrap()).unwrap();
pub fn listener(&self) -> UtpListener
[src]
Returns a [Stream
] of incoming connections.
Example
use libutp_rs::UtpContext; use std::error::Error; use futures::stream::StreamExt; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let ctx = UtpContext::bind("127.0.0.1:5000".parse()?)?; let mut listener = ctx.listener(); let socket = listener.next().await.unwrap()?; Ok(()) }
pub fn connect(&self, addr: SocketAddr) -> Connectⓘ
[src]
Initiates a connection.
Returns a Connect
future which resolves to a UtpSocket
if successful.
Example
use libutp_rs::UtpContext; use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let ctx = UtpContext::bind("127.0.0.1:5000".parse()?)?; let socket = ctx.connect("127.0.0.1:5001".parse()?).await?; Ok(()) }
pub fn set_udp_mtu(&self, mtu: u16)
[src]
pub fn clear_mtu(&self)
[src]
Auto Trait Implementations
impl RefUnwindSafe for UtpContext
impl Send for UtpContext
impl Sync for UtpContext
impl Unpin for UtpContext
impl UnwindSafe for UtpContext
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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.
pub 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>,