pub struct RequestIdAllocator {
role: Role,
next_id: u64,
max_id: u64,
}Expand description
Allocates and validates request IDs per the MoQT spec.
- Client: even IDs (0, 2, 4, …)
- Server: odd IDs (1, 3, 5, …)
- Default MAX_REQUEST_ID: 0 (no requests until increased)
- MAX_REQUEST_ID can only increase
Fields§
§role: Role§next_id: u64§max_id: u64Implementations§
Source§impl RequestIdAllocator
impl RequestIdAllocator
pub fn new(role: Role) -> Self
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).
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