Skip to content
Merged
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
13 changes: 10 additions & 3 deletions src/types/enc_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ use anyhow::Result;
use std::sync::Arc;
use wacore_binary::Node;

/// Trait for handling custom encrypted message types
#[async_trait::async_trait]
pub trait EncHandler: Send + Sync {
/// Trait for handling custom encrypted message types.
///
/// Mirrors the wasm-portability convention of the sibling extension points
/// (EventHandler, SendContextResolver): the `MaybeSendSync` supertrait keeps the
/// `Send + Sync` requirement on native (the client stores `Arc<dyn EncHandler>`
/// across receive lanes) while dropping it on wasm32, where the client is `!Send`
/// and a handler may hold `!Send` JS handles.
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
pub trait EncHandler: wacore::sync_marker::MaybeSendSync {
/// Handle an encrypted node of a specific type
///
/// # Arguments
Expand Down
Loading