Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conditional compilation of proposal references #68

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Build one feature at a time
run: cargo hack build --each-feature --workspace --exclude fuzz --exclude harness_client
run: cargo hack build --each-feature --workspace --exclude harness_client
15 changes: 7 additions & 8 deletions mls-rs/src/group/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use super::proposal::CustomProposal;
#[cfg(feature = "private_message")]
use crate::group::framing::PrivateMessage;

#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
#[cfg(feature = "by_ref_proposal")]
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

#[derive(Debug)]
Expand Down Expand Up @@ -276,6 +276,7 @@ impl TryFrom<Sender> for ProposalSender {
safer_ffi_gen::ffi_type(clone, opaque)
)]
#[derive(Debug, Clone)]
#[non_exhaustive]
/// Description of a processed MLS proposal message.
pub struct ProposalMessageDescription {
/// Sender of the proposal.
Expand All @@ -284,19 +285,19 @@ pub struct ProposalMessageDescription {
pub proposal: Proposal,
/// Plaintext authenticated data in the received MLS packet.
pub authenticated_data: Vec<u8>,
#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
pub(crate) proposal_ref: ProposalRef,
/// Proposal reference.
pub proposal_ref: ProposalRef,
}

#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
#[cfg(feature = "by_ref_proposal")]
#[derive(MlsSize, MlsEncode, MlsDecode)]
pub struct CachedProposal {
pub(crate) proposal: Proposal,
pub(crate) proposal_ref: ProposalRef,
pub(crate) sender: Sender,
}

#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
#[cfg(feature = "by_ref_proposal")]
impl CachedProposal {
/// Deserialize the proposal
pub fn from_bytes(bytes: &[u8]) -> Result<Self, MlsError> {
Expand All @@ -309,7 +310,7 @@ impl CachedProposal {
}
}

#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
#[cfg(feature = "by_ref_proposal")]
impl ProposalMessageDescription {
pub fn cached_proposal(self) -> CachedProposal {
let sender = match self.sender {
Expand Down Expand Up @@ -495,7 +496,6 @@ pub(crate) trait MessageProcessor: Send + Sync {
let group_state = self.group_state_mut();

if cache_proposal {
#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
let proposal_ref = proposal_ref.clone();

group_state.proposals.insert(
Expand All @@ -509,7 +509,6 @@ pub(crate) trait MessageProcessor: Send + Sync {
authenticated_data: auth_content.content.authenticated_data.clone(),
proposal: proposal.clone(),
sender: auth_content.content.sender.try_into()?,
#[cfg(all(feature = "by_ref_proposal", feature = "external_client"))]
proposal_ref,
})
}
Expand Down
Loading