openmls/extensions/
application_id_extension.rs

1use tls_codec::{TlsDeserialize, TlsDeserializeBytes, TlsSerialize, TlsSize, VLBytes};
2
3use super::{Deserialize, Serialize};
4
5/// # Application Identifiers
6///
7/// The application id extension allows applications to add an explicit,
8/// application-defined identifier to a [`LeafNode`](crate::treesync::LeafNode).
9#[derive(
10    PartialEq,
11    Eq,
12    Clone,
13    Debug,
14    Serialize,
15    Deserialize,
16    TlsSerialize,
17    TlsDeserialize,
18    TlsDeserializeBytes,
19    TlsSize,
20)]
21pub struct ApplicationIdExtension {
22    key_id: VLBytes,
23}
24
25impl ApplicationIdExtension {
26    /// Create a new key identifier extension from a byte slice.
27    pub fn new(id: &[u8]) -> Self {
28        Self { key_id: id.into() }
29    }
30
31    /// Get the value of the key id as byte slice.
32    pub fn as_slice(&self) -> &[u8] {
33        self.key_id.as_slice()
34    }
35}