pub struct SubscribeIdAllocator {
next_id: u64,
max_id: u64,
}Expand description
Allocates and validates subscribe IDs per the MoQT draft-08 spec.
Draft-07 has no client/server parity rule for subscribe IDs (unlike
the draft-14 request ID allocator). The subscriber allocates IDs
monotonically starting at 0; FETCH and SUBSCRIBE share the same
namespace since each carries a subscribe_id field.
Fields§
§next_id: u64§max_id: u64Implementations§
Source§impl SubscribeIdAllocator
impl SubscribeIdAllocator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new allocator starting at subscribe_id 0 with max_id = 0 (blocked until the peer sends MAX_SUBSCRIBE_ID).
Sourcepub fn allocate(&mut self) -> Result<VarInt, SubscribeIdError>
pub fn allocate(&mut self) -> Result<VarInt, SubscribeIdError>
Allocate the next subscribe ID.
Sourcepub fn update_max(&mut self, new_max: u64) -> Result<(), SubscribeIdError>
pub fn update_max(&mut self, new_max: u64) -> Result<(), SubscribeIdError>
Update the maximum allowed subscribe ID (can only increase).
Sourcepub fn validate_peer_id(&self, id: u64) -> Result<(), SubscribeIdError>
pub fn validate_peer_id(&self, id: u64) -> Result<(), SubscribeIdError>
Validate a subscribe ID received from the peer.
Sourcepub fn is_blocked(&self) -> bool
pub fn is_blocked(&self) -> bool
Check if we are blocked (max_id is 0 or next_id >= max_id).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SubscribeIdAllocator
impl RefUnwindSafe for SubscribeIdAllocator
impl Send for SubscribeIdAllocator
impl Sync for SubscribeIdAllocator
impl Unpin for SubscribeIdAllocator
impl UnsafeUnpin for SubscribeIdAllocator
impl UnwindSafe for SubscribeIdAllocator
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