Skip to main content

SrtSocket

Struct SrtSocket 

Source
pub struct SrtSocket { /* private fields */ }
Available on crate feature tokio only.
Expand description

A handle to an established SRT connection over UDP.

Created by SrtSocket::connect (caller role) or SrtListener::accept (listener role). The protocol itself runs on a background tokio task the handle owns; send enqueues an application payload and recv awaits a delivered one. Dropping the handle aborts the driver task.

Implementations§

Source§

impl SrtSocket

Source

pub async fn connect<A: ToSocketAddrs>( remote_addr: A, config: HandshakeConfig, ) -> Result<Self>

Connect to a remote SRT peer as a Caller.

Source

pub async fn connect_from<A: ToSocketAddrs>( local_addr: SocketAddr, remote_addr: A, config: HandshakeConfig, ) -> Result<Self>

Connect from a specific local address.

Source

pub async fn send(&mut self, payload: &[u8]) -> Result<()>

Enqueue a payload for transmission to the peer.

Returns immediately once the payload is handed to the driver task — actual transmission, ACK/NAK handling, and retransmission all happen on that task. Fails only if the driver task has stopped (peer shut down or connection error).

Source

pub fn peer_addr(&self) -> SocketAddr

The peer’s socket address.

Source

pub async fn recv(&mut self) -> Result<Option<Vec<u8>>>

Receive the next payload, waiting until one is available. Returns None once the peer has shut down (or the driver task has stopped) and no further payloads will arrive.

Trait Implementations§

Source§

impl Debug for SrtSocket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SrtSocket

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.