Skip to main content

Crate protocol_droid

Crate protocol_droid 

Source
Expand description

The protocol-droid library: one canonical IR, many per-revision codecs.

Application code in this crate speaks a version-agnostic superset IR. Each per-revision codec lifts wire messages into that IR on the way in and lowers them back to the wire on the way out, for whichever revision was negotiated with the peer. Every feature-specific path consults the session’s negotiated FeatureProfile before it runs.

The layer split is the project’s hexagonal layout:

  • domain — value objects, aggregates and pure functions. No I/O, no runtime, no framework derives.
  • application — one module per use case. Each declares its own narrow port trait inline, beside the handler that consumes it.
  • adapters::primary — driving adapters: the server transports.
  • adapters::secondary — driven adapters: the client transports, upstream peers, clocks, RNG and the filesystem.

There is deliberately no ports module. Port traits belong to the consumer, so they live in the application module that needs them, and are never collected into a shared module.

§What the attribute macros need

schemars, serde and serde_json are re-exported so code generated by #[server] names them through this crate. Generated code that spelled ::schemars and ::serde would force every user of a macro to depend on both crates themselves, at versions the macro happened to be built against, with no way to disagree — and a mismatch would be a compile error in generated code, which is the worst place to discover a version problem.

Re-exports§

pub use schemars;
pub use serde;
pub use serde_json;

Modules§

adapters
Adapters: the boundary between the core and the outside world.
application
Application layer: one module per use case.
domain
Domain layer: value objects, aggregates and pure functions.

Attribute Macros§

prompt
Marks a plain fn returning a Prompt as a prompt the server offers.
resource
Marks a plain fn returning a Resource as a resource the server lists.
server
Collects every marked method in an impl block into a Server.
tool
Marks an async fn as a tool.