pub struct Claims {
pub realm_id: u32,
pub key_id: u32,
pub token: Bytes,
}Expand description
TURN authentication claims.
Fields§
§realm_id: u32Realm identifier.
key_id: u32Key identifier used by the TURN auth cache.
token: BytesEncrypted token.
Implementations§
Source§impl Claims
impl Claims
pub fn new(realm_id: u32, key_id: u32, token: Bytes) -> Self
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encodes Claims into base122 string for TURN server compatibility
TURN servers only accept String usernames, so we encode the binary data:
Byte Layout (ASCII Table):
+----------+----------+-------------------+
| Byte 0-3 | Byte 4-7 | Byte 8+ |
+----------+----------+-------------------+
| realm_id | key_id | token |
| (u32 BE) | (u32 BE) | (variable len) |
+----------+----------+-------------------+The bytes are then encoded with base122 to create a valid String for TURN protocol compatibility.
Sourcepub fn decode(s: &str) -> Result<Self>
pub fn decode(s: &str) -> Result<Self>
Decodes base122 string back to Claims using bytes::Buf trait
Byte Layout (ASCII Table):
+----------+----------+-------------------+
| Byte 0-3 | Byte 4-7 | Byte 8+ |
+----------+----------+-------------------+
| realm_id | key_id | token |
| (u32 BE) | (u32 BE) | (variable len) |
+----------+----------+-------------------+Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Claims
impl RefUnwindSafe for Claims
impl Send for Claims
impl Sync for Claims
impl Unpin for Claims
impl UnwindSafe for Claims
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