[−][src]Struct srt_tokio::SrtSocketBuilder
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]
pub fn new_rendezvous(to: impl ToSocketAddrs) -> Self
[src]
#[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. This sets both the send and receive latency
pub fn receive_latency(self, latency: Duration) -> Self
[src]
pub fn send_latency(self, latency: Duration) -> Self
[src]
pub fn crypto(self, size: u8, passphrase: impl Into<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]
T: Stream<Item = Result<(Packet, SocketAddr), PacketParseError>> + Sink<(Packet, SocketAddr), Error = Error> + Unpin + Send + 'static,
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]
self
) -> Result<impl Stream<Item = Result<(Connection, PackChan), Error>>, Error>
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]
fn clone(&self) -> SrtSocketBuilder
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SrtSocketBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for SrtSocketBuilder
impl Send for SrtSocketBuilder
impl Sync for SrtSocketBuilder
impl Unpin for SrtSocketBuilder
impl UnwindSafe for SrtSocketBuilder
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,
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> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,