pub struct Endpoint {
role: Role,
session: SessionStateMachine,
request_ids: RequestIdAllocator,
subscriptions: HashMap<u64, SubscriptionStateMachine>,
fetches: HashMap<u64, FetchStateMachine>,
subscribe_namespaces: HashMap<u64, SubscribeNamespaceStateMachine>,
publish_namespaces: HashMap<u64, PublishNamespaceStateMachine>,
track_statuses: HashMap<u64, TrackStatusStateMachine>,
publishes: HashMap<u64, PublishStateMachine>,
goaway_uri: Option<Vec<u8>>,
}Fields§
§role: Role§session: SessionStateMachine§request_ids: RequestIdAllocator§subscriptions: HashMap<u64, SubscriptionStateMachine>§fetches: HashMap<u64, FetchStateMachine>§subscribe_namespaces: HashMap<u64, SubscribeNamespaceStateMachine>§publish_namespaces: HashMap<u64, PublishNamespaceStateMachine>§track_statuses: HashMap<u64, TrackStatusStateMachine>§publishes: HashMap<u64, PublishStateMachine>§goaway_uri: Option<Vec<u8>>Implementations§
Source§impl Endpoint
impl Endpoint
pub fn new(role: Role) -> Self
pub fn role(&self) -> Role
pub fn session_state(&self) -> SessionState
pub fn goaway_uri(&self) -> Option<&[u8]>
pub fn active_subscription_count(&self) -> usize
pub fn active_fetch_count(&self) -> usize
pub fn active_subscribe_namespace_count(&self) -> usize
pub fn active_publish_namespace_count(&self) -> usize
pub fn active_track_status_count(&self) -> usize
pub fn active_publish_count(&self) -> usize
pub fn connect(&mut self) -> Result<(), EndpointError>
pub fn close(&mut self) -> Result<(), EndpointError>
Sourcepub fn send_setup(
&mut self,
options: Vec<KeyValuePair>,
) -> Result<ControlMessage, EndpointError>
pub fn send_setup( &mut self, options: Vec<KeyValuePair>, ) -> Result<ControlMessage, EndpointError>
Generate a SETUP message. Both client and server use the same message type; only the role (and the order of send/receive) distinguishes them.
Sourcepub fn receive_setup(&mut self, msg: &Setup) -> Result<(), EndpointError>
pub fn receive_setup(&mut self, msg: &Setup) -> Result<(), EndpointError>
Process an incoming SETUP message. Transitions the session to Active.
pub fn receive_goaway(&mut self, msg: &GoAway) -> Result<(), EndpointError>
Sourcefn delta() -> VarInt
fn delta() -> VarInt
required_request_id_delta is the distance between this request_id
and the lowest still-pending one. For simplicity we always emit 0
(tells the peer “no earlier requests need a response before this one”).
fn require_active_or_err(&self) -> Result<(), EndpointError>
pub fn subscribe( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
Sourcepub fn receive_subscribe_ok(
&mut self,
request_id: VarInt,
_msg: &SubscribeOk,
) -> Result<(), EndpointError>
pub fn receive_subscribe_ok( &mut self, request_id: VarInt, _msg: &SubscribeOk, ) -> Result<(), EndpointError>
Process an incoming SUBSCRIBE_OK. Draft-17: no request_id on wire; the
caller supplies the request_id of the bidi stream on which the
response arrived.
Sourcepub fn receive_request_update(
&mut self,
msg: &RequestUpdate,
) -> Result<(), EndpointError>
pub fn receive_request_update( &mut self, msg: &RequestUpdate, ) -> Result<(), EndpointError>
Process REQUEST_UPDATE. Draft-17: renames draft-16’s
existing_request_id to request_id (the one being updated).
Sourcepub fn receive_publish_done(
&mut self,
request_id: VarInt,
_msg: &PublishDone,
) -> Result<(), EndpointError>
pub fn receive_publish_done( &mut self, request_id: VarInt, _msg: &PublishDone, ) -> Result<(), EndpointError>
Process an incoming PUBLISH_DONE (subscriber side). Draft-17: no
request_id on wire; request_id identifies the subscription’s
bidi stream.
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>
pub fn joining_fetch( &mut self, joining_request_id: VarInt, joining_start: VarInt, ) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn receive_fetch_ok( &mut self, request_id: VarInt, _msg: &FetchOk, ) -> Result<(), EndpointError>
pub fn on_fetch_stream_fin( &mut self, request_id: VarInt, ) -> Result<(), EndpointError>
pub fn on_fetch_stream_reset( &mut self, request_id: VarInt, ) -> Result<(), EndpointError>
pub fn subscribe_namespace( &mut self, namespace_prefix: TrackNamespace, subscribe_options: VarInt, parameters: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn publish_namespace( &mut self, track_namespace: TrackNamespace, 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>
pub fn publish( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, track_alias: VarInt, parameters: Vec<KeyValuePair>, track_properties: Vec<KeyValuePair>, ) -> Result<(VarInt, ControlMessage), EndpointError>
pub fn receive_publish_ok( &mut self, request_id: VarInt, _msg: &PublishOk, ) -> Result<(), EndpointError>
pub fn send_publish_done( &mut self, request_id: VarInt, status_code: VarInt, stream_count: VarInt, reason_phrase: Vec<u8>, ) -> Result<ControlMessage, EndpointError>
Sourcepub fn receive_request_ok(
&mut self,
request_id: VarInt,
_msg: &RequestOk,
) -> Result<(), EndpointError>
pub fn receive_request_ok( &mut self, request_id: VarInt, _msg: &RequestOk, ) -> Result<(), EndpointError>
Process an incoming REQUEST_OK on the bidi stream identified by
request_id. Used by PublishNamespace, SubscribeNamespace, and
TrackStatus flows.
Sourcepub fn receive_request_error(
&mut self,
request_id: VarInt,
_msg: &RequestError,
) -> Result<(), EndpointError>
pub fn receive_request_error( &mut self, request_id: VarInt, _msg: &RequestError, ) -> Result<(), EndpointError>
Process an incoming REQUEST_ERROR on the bidi stream identified by
request_id.
Sourcepub fn receive_namespace(
&mut self,
_msg: &Namespace,
) -> Result<(), EndpointError>
pub fn receive_namespace( &mut self, _msg: &Namespace, ) -> Result<(), EndpointError>
Receive an unsolicited NAMESPACE announcement. Informational — no state machine is involved.
Sourcepub fn receive_namespace_done(
&mut self,
_msg: &NamespaceDone,
) -> Result<(), EndpointError>
pub fn receive_namespace_done( &mut self, _msg: &NamespaceDone, ) -> Result<(), EndpointError>
Receive an unsolicited NAMESPACE_DONE announcement.
Sourcepub fn receive_publish_blocked(
&mut self,
_msg: &PublishBlocked,
) -> Result<(), EndpointError>
pub fn receive_publish_blocked( &mut self, _msg: &PublishBlocked, ) -> Result<(), EndpointError>
Receive a PUBLISH_BLOCKED notification.
Sourcepub fn receive_message(
&mut self,
msg: ControlMessage,
) -> Result<(), EndpointError>
pub fn receive_message( &mut self, msg: ControlMessage, ) -> Result<(), EndpointError>
Dispatch a message that arrived on the control stream (SETUP, GOAWAY, unsolicited announcements, RequestUpdate). Response messages belong on bidi request streams — they are rejected here.
Sourcepub fn receive_response_on_stream(
&mut self,
request_id: VarInt,
msg: ControlMessage,
) -> Result<(), EndpointError>
pub fn receive_response_on_stream( &mut self, request_id: VarInt, msg: ControlMessage, ) -> Result<(), EndpointError>
Dispatch a response message that arrived on the bidi request stream
identified by request_id (draft-17 §3.3). Accepts only the
response-bearing message types.