Skip to content

Commit

Permalink
Add API for examining roster of ExportedTree
Browse files Browse the repository at this point in the history
  • Loading branch information
Marta Mularczyk committed Jan 27, 2025
1 parent 539cc5c commit 1ee230c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mls-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mls-rs"
version = "0.44.0"
version = "0.44.1"
edition = "2021"
description = "An implementation of Messaging Layer Security (RFC 9420)"
homepage = "https://github.com/awslabs/mls-rs"
Expand Down
8 changes: 8 additions & 0 deletions mls-rs/src/group/exported_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

use crate::{client::MlsError, tree_kem::node::NodeVec};

use super::Roster;

#[cfg_attr(
all(feature = "ffi", not(test)),
safer_ffi_gen::ffi_type(clone, opaque)
Expand Down Expand Up @@ -35,6 +37,12 @@ impl<'a> ExportedTree<'a> {
pub fn into_owned(self) -> ExportedTree<'static> {
ExportedTree(Cow::Owned(self.0.into_owned()))
}

pub fn roster(&'a self) -> Roster<'a> {
Roster {
public_tree: &self.0,
}
}
}

#[cfg_attr(all(feature = "ffi", not(test)), ::safer_ffi_gen::safer_ffi_gen)]
Expand Down
10 changes: 7 additions & 3 deletions mls-rs/src/group/roster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use crate::tree_kem::node::NodeVec;

use super::*;

pub use mls_rs_core::group::Member;
Expand All @@ -21,7 +23,7 @@ pub(crate) fn member_from_leaf_node(leaf_node: &LeafNode, leaf_index: LeafIndex)
)]
#[derive(Clone, Debug)]
pub struct Roster<'a> {
pub(crate) public_tree: &'a TreeKemPublic,
pub(crate) public_tree: &'a NodeVec,
}

#[cfg_attr(all(feature = "ffi", not(test)), safer_ffi_gen::safer_ffi_gen)]
Expand Down Expand Up @@ -60,7 +62,7 @@ impl<'a> Roster<'a> {
let index = LeafIndex(index);

self.public_tree
.get_leaf_node(index)
.borrow_as_leaf(index)
.map(|l| member_from_leaf_node(l, index))
}

Expand All @@ -81,6 +83,8 @@ impl<'a> Roster<'a> {

impl TreeKemPublic {
pub(crate) fn roster(&self) -> Roster {
Roster { public_tree: self }
Roster {
public_tree: &self.nodes,
}
}
}

0 comments on commit 1ee230c

Please sign in to comment.