#![doc(
html_logo_url = "https://commonware.xyz/imgs/rustdoc_logo.svg",
html_favicon_url = "https://commonware.xyz/favicon.ico"
)]
commonware_macros::stability_scope!(ALPHA {
use commonware_actor::Feedback;
use commonware_codec::Codec;
use commonware_cryptography::{Committable, Digestible, PublicKey};
use commonware_p2p::Recipients;
use commonware_utils::channel::oneshot;
pub mod p2p;
pub trait Originator: Clone + Send + 'static {
type PublicKey: PublicKey;
type Request: Committable + Digestible + Codec;
fn send(
&mut self,
recipients: Recipients<Self::PublicKey>,
request: Self::Request,
) -> Feedback;
fn cancel(&mut self, commitment: <Self::Request as Committable>::Commitment) -> Feedback;
}
pub trait Handler: Clone + Send + 'static {
type PublicKey: PublicKey;
type Request: Committable + Digestible + Codec;
type Response: Committable<Commitment = <Self::Request as Committable>::Commitment>
+ Digestible<Digest = <Self::Request as Digestible>::Digest>
+ Codec;
fn process(
&mut self,
origin: Self::PublicKey,
request: Self::Request,
response: oneshot::Sender<Self::Response>,
);
}
pub trait Monitor: Clone + Send + 'static {
type PublicKey: PublicKey;
type Response: Committable + Digestible + Codec;
fn collected(
&mut self,
handler: Self::PublicKey,
response: Self::Response,
count: usize,
);
}
});