[][src]Struct srt::SrtSocketBuilder

#[must_use]pub struct SrtSocketBuilder { /* fields omitted */ }

Struct to build sockets.

This is the typical way to create instances of SrtSocket, which implements both Sink + Stream, as they can be both receivers and senders.

You need to decided on a ConnInitMethod in order to create a SrtSocketBuilder. See that documentation for more details.

Examples:

Simple:

let (a, b) = futures::try_join!(
    SrtSocketBuilder::new_listen().local_port(3333).connect(),
    SrtSocketBuilder::new_connect("127.0.0.1:3333").connect(),
)?;

Rendezvous example:

let (a, b) = futures::try_join!(
    SrtSocketBuilder::new_rendezvous("127.0.0.1:4444").local_port(5555).connect(),
    SrtSocketBuilder::new_rendezvous("127.0.0.1:5555").local_port(4444).connect(),
)?;

Panics:

  • There is no tokio runtime

Implementations

impl SrtSocketBuilder[src]

pub fn new(conn_type: ConnInitMethod) -> Self[src]

Defaults to binding to 0.0.0.0:0 (all adaptors, OS assigned port), 50ms latency, and no encryption. Generally easier to use new_listen, new_connect or new_rendezvous

pub fn new_listen() -> Self[src]

pub fn new_connect(to: impl ToSocketAddrs) -> Self[src]

Connects to the first address yielded by to

Panics

pub fn new_rendezvous(to: impl ToSocketAddrs) -> Self[src]

Connects to the first address yielded by to

Panics

#[must_use]pub fn conn_type(&self) -> &ConnInitMethod[src]

Gets the ConnInitMethod of the builder.

let builder = SrtSocketBuilder::new(ConnInitMethod::Listen);
assert_eq!(builder.conn_type(), &ConnInitMethod::Listen);

pub fn local_addr(self, local_addr: IpAddr) -> Self[src]

Sets the local address of the socket. This can be used to bind to just a specific network adapter instead of the default of all adapters.

pub fn local_port(self, port: u16) -> Self[src]

Sets the port to bind to. In general, to be used for ConnInitMethod::Listen and ConnInitMethod::Rendezvous, but generally not ConnInitMethod::Connect.

pub fn latency(self, latency: Duration) -> Self[src]

Set the latency of the connection. The more latency, the more time SRT has to recover lost packets.

pub fn crypto(self, size: u8, passphrase: String) -> Self[src]

Se the crypto paramters. However, this is currently unimplemented.

Panics:

  • size is not 16, 24, or 32.

pub async fn connect_with_sock<T>(self, __arg1: T) -> Result<SrtSocket, Error> where
    T: Stream<Item = Result<(Packet, SocketAddr), PacketParseError>> + Sink<(Packet, SocketAddr), Error = Error> + Unpin + Send + 'static, 
[src]

Connect with a custom socket. Not typically used, see connect instead.

pub async fn connect(self) -> Result<SrtSocket, Error>[src]

Connects to the remote socket. Resolves when it has been connected successfully.

pub async fn build_multiplexed(
    self
) -> Result<impl Stream<Item = Result<(Connection, PackChan), Error>>, Error>
[src]

Build a multiplexed connection. This acts as a sort of server, allowing many connections to this one socket.

Panics:

If this is built with a non-listen builder

Trait Implementations

impl Clone for SrtSocketBuilder[src]

impl Debug for SrtSocketBuilder[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,