Debian Codegraph @

third_party/rust/mls-rs/src/group/component_operation.rs

raw
1 use crate::client::MlsError;
2 use alloc::vec::Vec;
3 use mls_rs_codec::{MlsEncode, MlsSize};
4
5 pub type ComponentID = u32;
6
7 #[derive(Clone, Debug, PartialEq, MlsSize, MlsEncode)]
8 pub struct ComponentOperationLabel<'a> {
9 label: &'static [u8],
10 component_id: ComponentID,
11 context: &'a [u8],
12 }
13
14 impl<'a> ComponentOperationLabel<'a> {
15 pub fn new(component_id: u32, context: &'a [u8]) -> Self {
16 Self {
17 label: b"MLS 1.0 Application",
18 component_id,
19 context,
20 }
21 }
22
23 pub fn get_bytes(&self) -> Result<Vec<u8>, MlsError> {
24 self.mls_encode_to_vec().map_err(Into::into)
25 }
26 }