pub struct Connection {
quic: Connection,
endpoint: Endpoint,
control_send: Option<FramedSendStream>,
control_recv: Option<FramedRecvStream>,
}Expand description
A live MoQT connection over QUIC, combining the endpoint state machine with actual network I/O.
Fields§
§quic: Connection§endpoint: Endpoint§control_send: Option<FramedSendStream>§control_recv: Option<FramedRecvStream>Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn connect(
addr: &str,
config: ClientConfig,
) -> Result<Self, ConnectionError>
pub async fn connect( addr: &str, config: ClientConfig, ) -> Result<Self, ConnectionError>
Connect to a MoQT server as a client.
Opens a QUIC connection, performs the bidirectional control stream setup handshake (CLIENT_SETUP / SERVER_SETUP), and returns a ready-to-use connection.
Sourcepub async fn accept(
quic: Connection,
selected_version: VarInt,
) -> Result<Self, ConnectionError>
pub async fn accept( quic: Connection, selected_version: VarInt, ) -> Result<Self, ConnectionError>
Accept a MoQT connection as a server (given an already-accepted QUIC connection).
Sourcepub async fn send_control(
&mut self,
msg: &ControlMessage,
) -> Result<(), ConnectionError>
pub async fn send_control( &mut self, msg: &ControlMessage, ) -> Result<(), ConnectionError>
Send a control message on the control stream.
Sourcepub async fn recv_control(&mut self) -> Result<ControlMessage, ConnectionError>
pub async fn recv_control(&mut self) -> Result<ControlMessage, ConnectionError>
Read the next control message from the control stream.
Sourcepub async fn recv_and_dispatch(
&mut self,
) -> Result<ControlMessage, ConnectionError>
pub async fn recv_and_dispatch( &mut self, ) -> Result<ControlMessage, ConnectionError>
Read and dispatch the next incoming control message through the endpoint state machine. Returns the decoded message for inspection.
Sourcepub async fn subscribe(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
subscriber_priority: u8,
group_order: GroupOrder,
filter_type: FilterType,
) -> Result<VarInt, ConnectionError>
pub async fn subscribe( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, subscriber_priority: u8, group_order: GroupOrder, filter_type: FilterType, ) -> Result<VarInt, ConnectionError>
Send a SUBSCRIBE and return the allocated request ID.
Sourcepub async fn unsubscribe(
&mut self,
request_id: VarInt,
) -> Result<(), ConnectionError>
pub async fn unsubscribe( &mut self, request_id: VarInt, ) -> Result<(), ConnectionError>
Send an UNSUBSCRIBE for the given request ID.
Sourcepub async fn fetch(
&mut self,
track_namespace: TrackNamespace,
track_name: Vec<u8>,
start_group: VarInt,
start_object: VarInt,
) -> Result<VarInt, ConnectionError>
pub async fn fetch( &mut self, track_namespace: TrackNamespace, track_name: Vec<u8>, start_group: VarInt, start_object: VarInt, ) -> Result<VarInt, ConnectionError>
Send a FETCH and return the allocated request ID.
Sourcepub async fn fetch_cancel(
&mut self,
request_id: VarInt,
) -> Result<(), ConnectionError>
pub async fn fetch_cancel( &mut self, request_id: VarInt, ) -> Result<(), ConnectionError>
Send a FETCH_CANCEL for the given request ID.
Sourcepub async fn subscribe_namespace(
&mut self,
track_namespace: TrackNamespace,
) -> Result<VarInt, ConnectionError>
pub async fn subscribe_namespace( &mut self, track_namespace: TrackNamespace, ) -> Result<VarInt, ConnectionError>
Send a SUBSCRIBE_NAMESPACE and return the request ID.
Sourcepub async fn publish_namespace(
&mut self,
track_namespace: TrackNamespace,
) -> Result<VarInt, ConnectionError>
pub async fn publish_namespace( &mut self, track_namespace: TrackNamespace, ) -> Result<VarInt, ConnectionError>
Send a PUBLISH_NAMESPACE and return the request ID.
Sourcepub async fn open_subgroup_stream(
&self,
header: &SubgroupHeader,
) -> Result<FramedSendStream, ConnectionError>
pub async fn open_subgroup_stream( &self, header: &SubgroupHeader, ) -> Result<FramedSendStream, ConnectionError>
Open a new unidirectional stream for sending subgroup data.
Sourcepub async fn accept_subgroup_stream(
&self,
) -> Result<(SubgroupHeader, FramedRecvStream), ConnectionError>
pub async fn accept_subgroup_stream( &self, ) -> Result<(SubgroupHeader, FramedRecvStream), ConnectionError>
Accept an incoming unidirectional data stream and read its subgroup header.
Sourcepub fn send_datagram(
&self,
header: &DatagramHeader,
payload: &[u8],
) -> Result<(), ConnectionError>
pub fn send_datagram( &self, header: &DatagramHeader, payload: &[u8], ) -> Result<(), ConnectionError>
Send an object via datagram.
Sourcepub async fn recv_datagram(
&self,
) -> Result<(DatagramHeader, Vec<u8>), ConnectionError>
pub async fn recv_datagram( &self, ) -> Result<(DatagramHeader, Vec<u8>), ConnectionError>
Receive a datagram and decode its header.
Sourcepub fn endpoint_mut(&mut self) -> &mut Endpoint
pub fn endpoint_mut(&mut self) -> &mut Endpoint
Mutable access to the endpoint state machine.
Sourcepub fn negotiated_version(&self) -> Option<VarInt>
pub fn negotiated_version(&self) -> Option<VarInt>
Get the negotiated MoQT version.