Zer0 Proto Mp
Protocol Builder
Protocol builder in `zer0-proto-mp` — declarative composition of channels, schemas, and per-channel handlers.
Purpose
Protocol multiplexing with channels, frames, varints, schemas, handshakes, metrics, and stream integration.
This page follows the real source shape for Zer0 Proto Mp and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
Channel— libs/zer0-proto-mp/src/channel.rsChannelHandle— libs/zer0-proto-mp/src/channel.rsChannelId— libs/zer0-proto-mp/src/frame.rsChannelStats— libs/zer0-proto-mp/src/channel.rsFrame— libs/zer0-proto-mp/src/frame.rsHandshakeConfig— libs/zer0-proto-mp/src/protocol.rsMessageId— libs/zer0-proto-mp/src/protocol.rsMessageSchema— libs/zer0-proto-mp/src/protocol.rsMuxConfig— libs/zer0-proto-mp/src/config.rsMuxMetrics— libs/zer0-proto-mp/src/metrics.rsProtocol— libs/zer0-proto-mp/src/protocol.rsProtocolBuilder— libs/zer0-proto-mp/src/protocol.rs
Example shape
use zer0_proto_mp::protocol::{Protocol, ProtocolBuilder, ProtocolFeature};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// ProtocolBuilder accumulates name, version, and feature flags. Each
// channel registers a Protocol that the peer must support.
let protocol: Protocol = ProtocolBuilder::new("weave.control")
.version(2)
.feature(ProtocolFeature::FlowControl)
.feature(ProtocolFeature::Multiplexing)
.feature(ProtocolFeature::Compression)
.build()?;
// Protocols are negotiated during channel open; the peer side replies
// with a compatible Protocol or rejects the channel.
println!(
"name={} version={} feature_count={}",
protocol.name(),
protocol.version(),
protocol.features().len(),
);
Ok(())
}