Skip to main content

RtmpConnection

Struct RtmpConnection 

Source
pub struct RtmpConnection<S = BoxStream> { /* private fields */ }
Available on crate feature tokio only.
Expand description

One accepted RTMP connection: a stream (an erased BoxStream by default) driving a ServerSession.

next_events is the whole surface: read a chunk, drive the session, write the reply, return the events.

Implementations§

Source§

impl RtmpConnection<BoxStream>

Source

pub fn from_stream<S>(stream: S, config: RtmpServerConfig) -> Self
where S: RtmpStream + 'static,

Wraps an already-connected stream, erasing its type, and drives the session config carries: the constructor AsyncRtmpServer::accept uses, so one RtmpConnection names the connection whatever the transport. RtmpServerConfig::new carries a fresh session (a RtmpServerConfig) and the caller’s Timeouts.

Source

pub async fn next_events(&mut self) -> Result<Option<Vec<ServerEvent>>>

Reads one chunk from the socket, drives ServerSession::handle_data, writes the reply bytes back (all of them), and returns the resulting events.

Returns Ok(None) when the connection is finished: the peer closed the socket (clean EOF), or the most recent batch of events included ServerEvent::Eof (so the caller sees that final batch once, then None on the next call). Once a call returns None, every subsequent call also returns None without reading the socket again.

Cancel-safe: dropping the future at any await point loses neither a reply byte nor an event (the reply sits in the framed write buffer, the events in self, until a later call delivers them).

§Errors

An io::Error from the underlying socket read/write, or a mapped RtmpError (kind io::ErrorKind::InvalidData) from ServerSession::handle_data. On an RtmpError the session is unrecoverable (per handle_data’s own doc): this connection is torn down immediately — marked closed and not driven further, even if the caller keeps calling next_events. A deadline expiry (Timeouts) is io::ErrorKind::TimedOut and closes the connection too.

Trait Implementations§

Source§

impl<S: Debug> Debug for RtmpConnection<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Forget for RtmpConnection<S>

§

impl<S> Freeze for RtmpConnection<S>
where S: Freeze, *const u8 is !null: Freeze, *mut Shared: Freeze, PhantomData<u8>: Freeze, PhantomData<(DamageKind, Disposition)>: Freeze, *const LeafNode<ChunkStreamId, CsidState> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(ChunkStreamId, CsidState)>>: Freeze, PhantomData<Damage>: Freeze, PhantomData<ServerEvent>: Freeze,

§

impl<S> Move for RtmpConnection<S>

§

impl<S> RefUnwindSafe for RtmpConnection<S>

§

impl<S> Send for RtmpConnection<S>
where S: Send, BytesMut: Send, RawVecInner: Send, NodeRef<Owned, ChunkStreamId, CsidState, LeafOrInternal>: Send, BoxRaw<(ChunkStreamId, CsidState)>: Send, NonZero<u32>: Send, &'static str: Send, ServerEvent: Send,

§

impl<S> Sync for RtmpConnection<S>
where S: Sync, BytesMut: Sync, RawVecInner: Sync, NodeRef<Owned, ChunkStreamId, CsidState, LeafOrInternal>: Sync, BoxRaw<(ChunkStreamId, CsidState)>: Sync, NonZero<u32>: Sync, ServerEvent: Sync,

§

impl<S> Unpin for RtmpConnection<S>
where Framed<S, SessionCodec<ServerSession>>: Unpin, *const u8 is !null: Unpin, ServerEvent: Unpin,

§

impl<S> UnsafeUnpin for RtmpConnection<S>

§

impl<S> UnwindSafe for RtmpConnection<S>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.