pub struct RequestIdAllocator {
next_id: u64,
max_id: u64,
}Expand description
Allocates and validates request IDs per the MoQT draft-12 spec.
Draft-12 uses the same monotonic allocation rules as draft-11. The
subscriber allocates IDs monotonically starting at 0; SUBSCRIBE, FETCH,
PUBLISH, ANNOUNCE, etc. all share the same namespace since each carries a
request_id field.
Fields§
§next_id: u64§max_id: u64Implementations§
Source§impl RequestIdAllocator
impl RequestIdAllocator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new allocator starting at request_id 0 with max_id = 0 (blocked until the peer sends MAX_REQUEST_ID).
Sourcepub fn allocate(&mut self) -> Result<VarInt, RequestIdError>
pub fn allocate(&mut self) -> Result<VarInt, RequestIdError>
Allocate the next request ID.
Sourcepub fn update_max(&mut self, new_max: u64) -> Result<(), RequestIdError>
pub fn update_max(&mut self, new_max: u64) -> Result<(), RequestIdError>
Update the maximum allowed request ID (can only increase).
Sourcepub fn validate_peer_id(&self, id: u64) -> Result<(), RequestIdError>
pub fn validate_peer_id(&self, id: u64) -> Result<(), RequestIdError>
Validate a request 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 RequestIdAllocator
impl RefUnwindSafe for RequestIdAllocator
impl Send for RequestIdAllocator
impl Sync for RequestIdAllocator
impl Unpin for RequestIdAllocator
impl UnsafeUnpin for RequestIdAllocator
impl UnwindSafe for RequestIdAllocator
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