pub struct Endpoint {
role: Role,
session: SessionStateMachine,
request_ids: RequestIdAllocator,
advertised_max_id: u64,
subscriptions: HashMap<u64, SubscriptionStateMachine>,
fetches: HashMap<u64, FetchStateMachine>,
subscribe_namespaces: HashMap<u64, SubscribeNamespaceStateMachine>,
publish_namespaces: HashMap<u64, PublishNamespaceStateMachine>,
publish_namespace_namespaces: HashMap<u64, TrackNamespace>,
track_statuses: HashMap<u64, TrackStatusStateMachine>,
publishes: HashMap<u64, PublishStateMachine>,
goaway_uri: Option<Vec<u8>>,
}Expand description
Unified MoQT endpoint wrapping session lifecycle, request ID allocation, and all per-request state machines (subscriptions, fetches, namespaces).
Fields§
§role: Role§session: SessionStateMachine§request_ids: RequestIdAllocator§advertised_max_id: u64Tracks the MAX_REQUEST_ID we have advertised to the peer (monotonic).
subscriptions: HashMap<u64, SubscriptionStateMachine>§fetches: HashMap<u64, FetchStateMachine>§subscribe_namespaces: HashMap<u64, SubscribeNamespaceStateMachine>§publish_namespaces: HashMap<u64, PublishNamespaceStateMachine>§publish_namespace_namespaces: HashMap<u64, TrackNamespace>Maps publish_namespace request_id -> TrackNamespace for lookup by namespace (needed for PublishNamespaceDone/Cancel which use namespace instead of request_id).
track_statuses: HashMap<u64, TrackStatusStateMachine>§publishes: HashMap<u64, PublishStateMachine>§goaway_uri: Option<Vec<u8>>Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn session_state(&self) -> SessionState
pub fn session_state(&self) -> SessionState
Returns the current session state.
Sourcepub fn goaway_uri(&self) -> Option<&[u8]>
pub fn goaway_uri(&self) -> Option<&[u8]>
Returns the URI from a received GOAWAY message, if any.
Sourcepub fn is_blocked(&self) -> bool
pub fn is_blocked(&self) -> bool
Returns whether this endpoint is blocked on request ID allocation.
Sourcepub fn active_subscription_count(&self) -> usize
pub fn active_subscription_count(&self) -> usize
Returns the number of active subscription state machines.
Sourcepub fn active_fetch_count(&self) -> usize
pub fn active_fetch_count(&self) -> usize
Returns the number of active fetch state machines.
Sourcepub fn active_subscribe_namespace_count(&self) -> usize
pub fn active_subscribe_namespace_count(&self) -> usize
Returns the number of active subscribe-namespace state machines.
Sourcepub fn active_publish_namespace_count(&self) -> usize
pub fn active_publish_namespace_count(&self) -> usize
Returns the number of active publish-namespace state machines.
Sourcepub fn active_track_status_count(&self) -> usize
pub fn active_track_status_count(&self) -> usize
Returns the number of active track status state machines.
Sourcepub fn active_publish_count(&self) -> usize
pub fn active_publish_count(&self) -> usize
Returns the number of active publish state machines.
Sourcepub fn connect(&mut self) -> Result<(), EndpointError>
pub fn connect(&mut self) -> Result<(), EndpointError>
Transition from Connecting to SetupExchange.
Sourcepub fn close(&mut self) -> Result<(), EndpointError>
pub fn close(&mut self) -> Result<(), EndpointError>
Close the session (Active or Draining -> Closed).
Sourcepub fn send_client_setup(
&mut self,
parameters: Vec<KeyValuePair>,
) -> Result<ControlMessage, EndpointError>
pub fn send_client_setup( &mut self, parameters: Vec<KeyValuePair>, ) -> Result<ControlMessage, EndpointError>
Generate a CLIENT_SETUP message (client-side). Draft-15 uses ALPN for version negotiation – no versions field.
Sourcepub fn receive_server_setup(
&mut self,
msg: &ServerSetup,
) -> Result<(), EndpointError>
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_REQUEST_ID parameter (key 0x02), the request ID allocator is initialized with that value.
Sourcepub fn receive_client_setup_and_respond(
&mut self,
client_setup: &ClientSetup,
) -> Result<ControlMessage, EndpointError>
pub fn receive_client_setup_and_respond( &mut self, client_setup: &ClientSetup, ) -> Result<ControlMessage, EndpointError>
Process CLIENT_SETUP and generate SERVER_SETUP (server-side). Draft-15 uses ALPN for version negotiation – just transition and respond.
Sourcepub fn receive_max_request_id(
&mut self,
msg: &MaxRequestId,
) -> Result<(), EndpointError>
pub fn receive_max_request_id( &mut self, msg: &MaxRequestId, ) -> Result<(), EndpointError>
Process an incoming MAX_REQUEST_ID message.
Sourcepub fn send_max_request_id(
&mut self,
max_id: VarInt,
) -> Result<ControlMessage, EndpointError>
pub fn send_max_request_id( &mut self, max_id: VarInt, ) -> Result<ControlMessage, EndpointError>
Generate a MAX_REQUEST_ID message (typically server-side). The value must strictly increase over previous sends.
Sourcepub fn send_requests_blocked(&self) -> Result<ControlMessage, EndpointError>
pub fn send_requests_blocked(&self) -> Result<ControlMessage, EndpointError>
Generate a REQUESTS_BLOCKED message indicating that this endpoint wants to create a new request but is blocked by the current MAX_REQUEST_ID.
Sourcepub fn receive_requests_blocked(
&self,
_msg: &RequestsBlocked,
) -> Result<(), EndpointError>
pub fn receive_requests_blocked( &self, _msg: &RequestsBlocked, ) -> Result<(), EndpointError>
Process an incoming REQUESTS_BLOCKED message from the peer.
Sourcepub fn receive_goaway(&mut self, msg: &GoAway) -> Result<(), EndpointError>
pub fn receive_goaway(&mut self, msg: &GoAway) -> Result<(), EndpointError>
Process an incoming GOAWAY message. Transitions to Draining.
fn require_active_or_err(&self) -> Result<(), EndpointError>
Sourcepub fn subscribe(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
parameters: Vec<KeyValuePair>,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn subscribe( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a SUBSCRIBE message. Allocates a request ID and creates a subscription state machine. Draft-15: simplified, no group_order/ filter_type/forward args.
Sourcepub fn receive_subscribe_ok(
&mut self,
msg: &SubscribeOk,
) -> Result<(), EndpointError>
pub fn receive_subscribe_ok( &mut self, msg: &SubscribeOk, ) -> Result<(), EndpointError>
Process an incoming SUBSCRIBE_OK. Draft-15: has request_id, track_alias, parameters.
Sourcepub fn unsubscribe(
&mut self,
request_id: VarInt,
) -> Result<ControlMessage, EndpointError>
pub fn unsubscribe( &mut self, request_id: VarInt, ) -> Result<ControlMessage, EndpointError>
Send an UNSUBSCRIBE message for an active subscription.
Sourcepub fn receive_subscribe_update(
&mut self,
msg: &SubscribeUpdate,
) -> Result<(), EndpointError>
pub fn receive_subscribe_update( &mut self, msg: &SubscribeUpdate, ) -> Result<(), EndpointError>
Process an incoming SUBSCRIBE_UPDATE. Draft-15: uses subscription_request_id to find the original subscription.
Sourcepub fn receive_publish_done(
&mut self,
msg: &PublishDone,
) -> Result<(), EndpointError>
pub fn receive_publish_done( &mut self, msg: &PublishDone, ) -> Result<(), EndpointError>
Process an incoming PUBLISH_DONE (subscriber side – publisher finished). Draft-15: has request_id, status_code, stream_count, reason_phrase.
Sourcepub fn fetch(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
start_group: VarInt,
start_object: VarInt,
end_group: VarInt,
end_object: VarInt,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn fetch( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, start_group: VarInt, start_object: VarInt, end_group: VarInt, end_object: VarInt, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a standalone FETCH message. Allocates a request ID and creates a fetch state machine. Draft-15: has end_object.
Sourcepub fn joining_fetch(
&mut self,
joining_request_id: VarInt,
joining_start: VarInt,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn joining_fetch( &mut self, joining_request_id: VarInt, joining_start: VarInt, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a joining FETCH message. Allocates a request ID.
Sourcepub fn receive_fetch_ok(&mut self, msg: &FetchOk) -> Result<(), EndpointError>
pub fn receive_fetch_ok(&mut self, msg: &FetchOk) -> Result<(), EndpointError>
Process an incoming FETCH_OK. Draft-15: has request_id, end_of_track, end_group, end_object, parameters.
Sourcepub fn fetch_cancel(
&mut self,
request_id: VarInt,
) -> Result<ControlMessage, EndpointError>
pub fn fetch_cancel( &mut self, request_id: VarInt, ) -> Result<ControlMessage, EndpointError>
Send a FETCH_CANCEL message.
Sourcepub fn on_fetch_stream_fin(
&mut self,
request_id: VarInt,
) -> Result<(), EndpointError>
pub fn on_fetch_stream_fin( &mut self, request_id: VarInt, ) -> Result<(), EndpointError>
Notify that a fetch data stream received FIN.
Sourcepub fn on_fetch_stream_reset(
&mut self,
request_id: VarInt,
) -> Result<(), EndpointError>
pub fn on_fetch_stream_reset( &mut self, request_id: VarInt, ) -> Result<(), EndpointError>
Notify that a fetch data stream was reset.
Sourcepub fn subscribe_namespace(
&mut self,
namespace_prefix: TrackNamespace,
parameters: Vec<KeyValuePair>,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn subscribe_namespace( &mut self, namespace_prefix: TrackNamespace, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a SUBSCRIBE_NAMESPACE message. Draft-15: uses namespace_prefix.
Sourcepub fn unsubscribe_namespace(
&mut self,
request_id: VarInt,
) -> Result<ControlMessage, EndpointError>
pub fn unsubscribe_namespace( &mut self, request_id: VarInt, ) -> Result<ControlMessage, EndpointError>
Send an UNSUBSCRIBE_NAMESPACE message. Draft-15: just request_id.
Sourcepub fn publish_namespace(
&mut self,
track_namespace: TrackNamespace,
parameters: Vec<KeyValuePair>,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn publish_namespace( &mut self, track_namespace: TrackNamespace, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a PUBLISH_NAMESPACE message.
Sourcepub fn receive_publish_namespace_done(
&mut self,
msg: &PublishNamespaceDone,
) -> Result<(), EndpointError>
pub fn receive_publish_namespace_done( &mut self, msg: &PublishNamespaceDone, ) -> Result<(), EndpointError>
Process an incoming PUBLISH_NAMESPACE_DONE. Draft-15: uses track_namespace instead of request_id. Looks up by namespace.
Sourcepub fn publish_namespace_cancel(
&mut self,
track_namespace: TrackNamespace,
error_code: VarInt,
reason_phrase: Vec<u8>,
) -> Result<ControlMessage, EndpointError>
pub fn publish_namespace_cancel( &mut self, track_namespace: TrackNamespace, error_code: VarInt, reason_phrase: Vec<u8>, ) -> Result<ControlMessage, EndpointError>
Send a PUBLISH_NAMESPACE_CANCEL message. Draft-15: uses track_namespace, error_code, reason_phrase (no request_id on wire).
Sourcepub fn track_status(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
parameters: Vec<KeyValuePair>,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn track_status( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a TRACK_STATUS message. Allocates a request ID. Draft-15: simplified with parameters.
Sourcepub fn publish(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
track_alias: VarInt,
parameters: Vec<KeyValuePair>,
) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn publish( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, track_alias: VarInt, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Send a PUBLISH message (publisher side). Allocates a request ID. Draft-15: takes track_alias, no forward.
Sourcepub fn receive_publish_ok(
&mut self,
msg: &PublishOk,
) -> Result<(), EndpointError>
pub fn receive_publish_ok( &mut self, msg: &PublishOk, ) -> Result<(), EndpointError>
Process an incoming PUBLISH_OK (publisher side). Draft-15: has request_id, parameters.
Sourcepub fn send_publish_done(
&mut self,
request_id: VarInt,
status_code: VarInt,
stream_count: VarInt,
reason_phrase: Vec<u8>,
) -> Result<ControlMessage, EndpointError>
pub fn send_publish_done( &mut self, request_id: VarInt, status_code: VarInt, stream_count: VarInt, reason_phrase: Vec<u8>, ) -> Result<ControlMessage, EndpointError>
Send a PUBLISH_DONE message (publisher finishing). Draft-15: has stream_count.
Sourcepub fn receive_request_ok(
&mut self,
msg: &RequestOk,
) -> Result<(), EndpointError>
pub fn receive_request_ok( &mut self, msg: &RequestOk, ) -> Result<(), EndpointError>
Process an incoming REQUEST_OK (consolidated ok for namespace/ track-status flows).
Sourcepub fn receive_request_error(
&mut self,
msg: &RequestError,
) -> Result<(), EndpointError>
pub fn receive_request_error( &mut self, msg: &RequestError, ) -> Result<(), EndpointError>
Process an incoming REQUEST_ERROR (consolidated error).
Sourcepub fn receive_message(
&mut self,
msg: ControlMessage,
) -> Result<(), EndpointError>
pub fn receive_message( &mut self, msg: ControlMessage, ) -> Result<(), EndpointError>
Dispatch an incoming control message to the appropriate handler.