zer0-proto-mp · protocol
Source declarations, signatures and documentation for protocol.
Source: sigil/weave/libs/zer0-proto-mp/src/protocol.rs. SHA-256: e18dbb11dccaf443e5a2d2fc6c777f9d6fad2a4f8d49234a73fd535e6f2e2c5e.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
protocol::Version
Protocol version
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Version {
pub major: u16,
pub minor: u16,
pub patch: u16
}Source line: 17.
protocol::Version::new
pub fn new(major: u16, minor: u16, patch: u16) -> Self;Source line: 24.
protocol::MessageId
Message ID
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct MessageId(pub u32);Source line: 41.
protocol::Encoding
Message encoding type
#[derive(Debug, Clone)]
pub enum Encoding {
/// Raw binary data
Binary,
/// JSON encoding
Json,
/// Protocol Buffers
#[cfg(feature = "protobuf")]
Protobuf(String), // Type URL
/// Custom encoding
Custom(String),
}Source line: 45.
protocol::MessageHandler
Message handler function type
pub type MessageHandler = Arc<
dyn Fn(MessageId, Bytes) -> Pin<Box<dyn Future<Output = crate::Result<Option<Bytes>>> + Send>>
+ Send
+ Sync,
>;Source line: 58.
protocol::MessageSchema
Message schema definition
#[derive(Clone)]
pub struct MessageSchema {
pub id: MessageId,
pub encoding: Encoding,
pub handler: Option<MessageHandler>
}Source line: 66.
protocol::HandshakeConfig
Handshake configuration
pub struct HandshakeConfig {
pub timeout: std::time::Duration,
pub data: Box<HandshakeDataFn>,
pub verify: Box<HandshakeVerifyFn>
}Source line: 83.
protocol::Protocol
Protocol definition
#[derive(Debug, Clone)]
pub struct Protocol {
/// Protocol name (e.g., "zer0.echo.1")
pub name: String,
/// Protocol version
pub version: Version,
/// Message definitions
pub messages: Vec<MessageSchema>,
pub handshake: Option<Arc<HandshakeConfig>>,
/// Optional scheduling weight for WFQ (>=1)
pub weight: u32
}Source line: 99.
protocol::Protocol::builder
Create a new protocol builder
pub fn builder() -> ProtocolBuilder;Source line: 113.
protocol::Protocol::find_message
Find a message schema by ID
pub fn find_message(&self, id: MessageId) -> Option<&MessageSchema>;Source line: 118.
protocol::ProtocolBuilder
Protocol builder for ergonomic protocol creation
pub struct ProtocolBuilder {
}Source line: 124.
protocol::ProtocolBuilder::new
pub fn new() -> Self;Source line: 133.
protocol::ProtocolBuilder::name
pub fn name(mut self, name: impl Into<String>) -> Self;Source line: 143.
protocol::ProtocolBuilder::version
pub fn version(mut self, major: u16, minor: u16, patch: u16) -> Self;Source line: 148.
protocol::ProtocolBuilder::message
pub fn message(mut self, id: u32, encoding: Encoding) -> Self;Source line: 153.
protocol::ProtocolBuilder::message_with_handler
pub fn message_with_handler<F, Fut>(mut self, id: u32, encoding: Encoding, handler: F) -> Self
where
F: Fn(MessageId, Bytes) -> Fut + Send + Sync + 'static,
Fut: Future<Output = crate::Result<Option<Bytes>>> + Send + 'static,;Source line: 162.
protocol::ProtocolBuilder::handshake
pub fn handshake(mut self, config: HandshakeConfig) -> Self;Source line: 175.
protocol::ProtocolBuilder::weight
Set a scheduling weight for this protocol (>=1). Higher means more share.
pub fn weight(mut self, weight: u32) -> Self;Source line: 181.
protocol::ProtocolBuilder::build
pub fn build(self) -> Protocol;Source line: 186.