Skip to main content

Endpoint

Struct Endpoint 

Source
pub struct Endpoint {
    session: SessionStateMachine,
    subscribe_ids: SubscribeIdAllocator,
    advertised_max_id: u64,
    subscriptions: HashMap<u64, SubscriptionStateMachine>,
    fetches: HashMap<u64, FetchStateMachine>,
    subscribe_announces: HashMap<Vec<Vec<u8>>, SubscribeAnnouncesStateMachine>,
    announces: HashMap<Vec<Vec<u8>>, AnnounceStateMachine>,
    track_statuses: HashMap<(Vec<Vec<u8>>, Vec<u8>), TrackStatusStateMachine>,
    negotiated_version: Option<VarInt>,
    offered_versions: Vec<VarInt>,
    goaway_uri: Option<Vec<u8>>,
    peer_reported_max_subscribe_id: Option<VarInt>,
}
Expand description

Unified draft-08 MoQT endpoint wrapping session lifecycle, subscribe ID allocation, and all per-flow state machines (subscriptions, fetches, announces, subscribe-announces, track statuses).

Fields§

§session: SessionStateMachine§subscribe_ids: SubscribeIdAllocator§advertised_max_id: u64

Tracks the MAX_SUBSCRIBE_ID we have advertised to the peer.

§subscriptions: HashMap<u64, SubscriptionStateMachine>§fetches: HashMap<u64, FetchStateMachine>§subscribe_announces: HashMap<Vec<Vec<u8>>, SubscribeAnnouncesStateMachine>§announces: HashMap<Vec<Vec<u8>>, AnnounceStateMachine>§track_statuses: HashMap<(Vec<Vec<u8>>, Vec<u8>), TrackStatusStateMachine>§negotiated_version: Option<VarInt>§offered_versions: Vec<VarInt>§goaway_uri: Option<Vec<u8>>§peer_reported_max_subscribe_id: Option<VarInt>

The most recent maximum_subscribe_id reported by the peer via a SUBSCRIBES_BLOCKED message (draft-08 only).

Implementations§

Source§

impl Endpoint

Source

pub fn new() -> Self

Create a new draft-08 endpoint.

Source

pub fn session_state(&self) -> SessionState

Returns the current session state.

Source

pub fn negotiated_version(&self) -> Option<VarInt>

Returns the negotiated MoQT version, if setup is complete.

Source

pub fn goaway_uri(&self) -> Option<&[u8]>

Returns the URI from a received GOAWAY message, if any.

Source

pub fn is_blocked(&self) -> bool

Returns whether this endpoint is blocked on subscribe ID allocation.

Source

pub fn active_subscription_count(&self) -> usize

Returns the number of active subscription state machines.

Source

pub fn active_fetch_count(&self) -> usize

Returns the number of active fetch state machines.

Source

pub fn active_subscribe_announces_count(&self) -> usize

Returns the number of active subscribe-announces state machines.

Source

pub fn active_announce_count(&self) -> usize

Returns the number of active announce state machines.

Source

pub fn active_track_status_count(&self) -> usize

Returns the number of active track status state machines.

Source

pub fn connect(&mut self) -> Result<(), EndpointError>

Transition from Connecting to SetupExchange.

Source

pub fn close(&mut self) -> Result<(), EndpointError>

Close the session (Active or Draining -> Closed).

Source

pub fn send_client_setup( &mut self, versions: Vec<VarInt>, parameters: Vec<KeyValuePair>, ) -> Result<ControlMessage, EndpointError>

Generate a CLIENT_SETUP message (client-side).

Source

pub fn receive_server_setup( &mut self, msg: &ServerSetup, ) -> Result<(), EndpointError>

Process a SERVER_SETUP message (client-side). Transitions to Active. If the server includes a MAX_SUBSCRIBE_ID parameter (key 0x02), the subscribe ID allocator is initialized with that value.

Source

pub fn receive_client_setup_and_respond( &mut self, client_setup: &ClientSetup, selected_version: VarInt, ) -> Result<ControlMessage, EndpointError>

Process CLIENT_SETUP and generate SERVER_SETUP (server-side).

Source

pub fn receive_max_subscribe_id( &mut self, msg: &MaxSubscribeId, ) -> Result<(), EndpointError>

Process an incoming MAX_SUBSCRIBE_ID message.

Source

pub fn send_max_subscribe_id( &mut self, max_id: VarInt, ) -> Result<ControlMessage, EndpointError>

Generate a MAX_SUBSCRIBE_ID message (typically server-side). The value must strictly increase over previous sends.

Source

pub fn receive_goaway(&mut self, msg: &GoAway) -> Result<(), EndpointError>

Process an incoming GOAWAY message. Transitions to Draining.

Source

fn require_active_or_err(&self) -> Result<(), EndpointError>

Source

pub fn subscribe( &mut self, track_alias: VarInt, track_namespace: TrackNamespace, track_name: Vec<u8>, subscriber_priority: u8, group_order: GroupOrder, filter_type: FilterType, ) -> Result<(VarInt, ControlMessage), EndpointError>

Send a SUBSCRIBE message. Allocates a subscribe ID and creates a subscription state machine.

Source

pub fn receive_subscribe_ok( &mut self, msg: &SubscribeOk, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_OK.

Source

pub fn receive_subscribe_error( &mut self, msg: &SubscribeError, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_ERROR.

Source

pub fn unsubscribe( &mut self, subscribe_id: VarInt, ) -> Result<ControlMessage, EndpointError>

Send an UNSUBSCRIBE message for an active subscription.

Source

pub fn receive_subscribe_update( &mut self, msg: &SubscribeUpdate, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_UPDATE.

Source

pub fn receive_subscribe_done( &mut self, msg: &SubscribeDone, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_DONE (subscriber side — publisher finished).

Source

pub fn fetch( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, subscriber_priority: u8, group_order: GroupOrder, start_group: VarInt, start_object: VarInt, end_group: VarInt, end_object: VarInt, ) -> Result<(VarInt, ControlMessage), EndpointError>

Send a FETCH message. Allocates a subscribe ID and creates a fetch state machine.

Source

pub fn joining_fetch( &mut self, subscriber_priority: u8, group_order: GroupOrder, joining_subscribe_id: VarInt, preceding_group_offset: VarInt, ) -> Result<(VarInt, ControlMessage), EndpointError>

Send a joining FETCH message that attaches to an existing subscription. Allocates a new subscribe ID for the fetch and tracks it in its own fetch state machine.

Source

pub fn receive_fetch_ok(&mut self, msg: &FetchOk) -> Result<(), EndpointError>

Process an incoming FETCH_OK.

Source

pub fn receive_fetch_error( &mut self, msg: &FetchError, ) -> Result<(), EndpointError>

Process an incoming FETCH_ERROR.

Source

pub fn fetch_cancel( &mut self, subscribe_id: VarInt, ) -> Result<ControlMessage, EndpointError>

Send a FETCH_CANCEL message.

Source

pub fn on_fetch_stream_fin( &mut self, subscribe_id: VarInt, ) -> Result<(), EndpointError>

Notify that a fetch data stream received FIN.

Source

pub fn on_fetch_stream_reset( &mut self, subscribe_id: VarInt, ) -> Result<(), EndpointError>

Notify that a fetch data stream was reset.

Source

pub fn subscribe_announces( &mut self, track_namespace_prefix: TrackNamespace, ) -> Result<ControlMessage, EndpointError>

Send a SUBSCRIBE_ANNOUNCES message.

Source

pub fn receive_subscribe_announces_ok( &mut self, msg: &SubscribeAnnouncesOk, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_ANNOUNCES_OK.

Source

pub fn receive_subscribe_announces_error( &mut self, msg: &SubscribeAnnouncesError, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBE_ANNOUNCES_ERROR.

Source

pub fn unsubscribe_announces( &mut self, track_namespace_prefix: TrackNamespace, ) -> Result<ControlMessage, EndpointError>

Send an UNSUBSCRIBE_ANNOUNCES message.

Source

pub fn announce( &mut self, track_namespace: TrackNamespace, ) -> Result<ControlMessage, EndpointError>

Send an ANNOUNCE message.

Source

pub fn receive_announce_ok( &mut self, msg: &AnnounceOk, ) -> Result<(), EndpointError>

Process an incoming ANNOUNCE_OK.

Source

pub fn receive_announce_error( &mut self, msg: &AnnounceError, ) -> Result<(), EndpointError>

Process an incoming ANNOUNCE_ERROR.

Source

pub fn receive_announce_cancel( &mut self, msg: &AnnounceCancel, ) -> Result<(), EndpointError>

Process an incoming ANNOUNCE_CANCEL.

Source

pub fn unannounce( &mut self, track_namespace: TrackNamespace, ) -> Result<ControlMessage, EndpointError>

Send an UNANNOUNCE message (publisher withdrawing).

Source

pub fn track_status_request( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, ) -> Result<ControlMessage, EndpointError>

Send a TRACK_STATUS_REQUEST message.

Source

pub fn receive_track_status( &mut self, msg: &TrackStatus, ) -> Result<(), EndpointError>

Process an incoming TRACK_STATUS reply.

Source

pub fn receive_subscribes_blocked( &mut self, msg: &SubscribesBlocked, ) -> Result<(), EndpointError>

Process an incoming SUBSCRIBES_BLOCKED.

Draft-08 adds this message so the peer can explicitly report that a new subscribe id would exceed our advertised maximum. The endpoint records the peer’s reported maximum; acting on it (issuing a new MAX_SUBSCRIBE_ID) is up to the caller.

Source

pub fn peer_reported_max_subscribe_id(&self) -> Option<VarInt>

The maximum subscribe id that the peer most recently reported in a SUBSCRIBES_BLOCKED message, if any.

Source

pub fn receive_message( &mut self, msg: ControlMessage, ) -> Result<(), EndpointError>

Dispatch an incoming control message to the appropriate handler.

Trait Implementations§

Source§

impl Default for Endpoint

Source§

fn default() -> Self

Returns the “default value” for a type. 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more