pub struct AdaptiveStreamController { /* private fields */ }Expand description
Adaptive streaming controller
Implementations§
Source§impl AdaptiveStreamController
impl AdaptiveStreamController
Sourcepub async fn create_session(
&self,
data: Value,
options: StreamOptions,
) -> PjsResult<String>
pub async fn create_session( &self, data: Value, options: StreamOptions, ) -> PjsResult<String>
Create new streaming session
Sourcepub async fn start_streaming(&self, session_id: &str) -> PjsResult<()>
pub async fn start_streaming(&self, session_id: &str) -> PjsResult<()>
Start streaming frames for session
Sourcepub async fn handle_frame_ack(
&self,
session_id: &str,
frame_id: u32,
processing_time_ms: u64,
) -> PjsResult<()>
pub async fn handle_frame_ack( &self, session_id: &str, frame_id: u32, processing_time_ms: u64, ) -> PjsResult<()>
Handle frame acknowledgment
Sourcepub fn subscribe_frames(&self) -> Receiver<(String, WsMessage)>
pub fn subscribe_frames(&self) -> Receiver<(String, WsMessage)>
Get subscriber for frame events
Sourcepub async fn set_rate_limit_guard(
&self,
session_id: &str,
guard: RateLimitGuard,
) -> PjsResult<()>
pub async fn set_rate_limit_guard( &self, session_id: &str, guard: RateLimitGuard, ) -> PjsResult<()>
Set rate limit guard for a session
Sourcepub async fn validate_message(
&self,
session_id: &str,
frame_size: usize,
) -> PjsResult<()>
pub async fn validate_message( &self, session_id: &str, frame_size: usize, ) -> PjsResult<()>
Validate message against rate limits
Sourcepub async fn remove_session(&self, session_id: &str) -> bool
pub async fn remove_session(&self, session_id: &str) -> bool
Remove a single session by id.
Returns true if the session existed and was removed, false if the id
was not present. Callers may safely invoke this multiple times — the
second call is a no-op.
§Examples
let controller = AdaptiveStreamController::new();
let id = controller.create_session(json!({}), StreamOptions::default()).await.unwrap();
assert!(controller.remove_session(&id).await);
// Idempotent — second call is a no-op:
assert!(!controller.remove_session(&id).await);Sourcepub async fn cleanup_expired_sessions(&self, max_age: Duration)
pub async fn cleanup_expired_sessions(&self, max_age: Duration)
Clean up expired sessions
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AdaptiveStreamController
impl !UnwindSafe for AdaptiveStreamController
impl Freeze for AdaptiveStreamController
impl Send for AdaptiveStreamController
impl Sync for AdaptiveStreamController
impl Unpin for AdaptiveStreamController
impl UnsafeUnpin for AdaptiveStreamController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more