Skip to main content

Crate crucible_wire

Crate crucible_wire 

Source
Expand description

What a crucible server and a crucible client agree on about the wire, with no HTTP stack: operation descriptions, the error model, validation, timestamps, blobs, and the JSON readers and writers both sides use. The crucible and crucible-client-runtime-rust crates re-export it at the same paths, so generated model code compiles against either.

Modules§

blob
A blob: bytes. Inside a JSON body a blob is base64 (the standard alphabet, padded); as an @httpPayload it is the whole HTTP body, raw.
bound
Reading an input from its bound members (labels, query parameters, headers) and its JSON body in one pass: a deserializer that presents both as one map, so the typed input is built straight from the request with no JSON value in between. An @httpPayload member is bound too: the body’s bytes, handed to the Blob without a copy.
codec
Composable wire codecs for native collections, without public wrapper types.
error
Errors. An implementation returns crucible_server_runtime_rust::Result<T> and may fail with anything: a modelled error, or any other error through ?. The framework decides afterwards what reaches the caller (see docs/framework.md).
field
Presence of a model member, independently of its value’s nullability.
mcp
Static MCP contracts carried by generated service metadata.
number
Exact arbitrary-precision model numbers serialized as JSON numeric tokens.
object
Crucible JSON encodes a structure as a JSON object, and only as one. serde’s derived struct visitor also takes a sequence of positional values, and serde_json offers one for [: left alone, [] or ["Oslo", 1] would read as a structure, at any depth of a body or as a whole @httpPayload. Objects wraps a deserializer so every structure it reaches is refused unless it is a map. Every typed JSON read of a model value goes through it, so the server and the Rust client agree.
open
Shared serde machinery for forward-compatible client enums and unions.
operation
What generated code tells the framework about a service and its operations. All of it is 'static data built at compile time, so routing, binding and logging read it without allocation.
permissions
The static description of a model’s permissions, as generated code states it: the resources that declare permissions, each permission, and what each operation requires (Operation::REQUIREMENTS), plus the per-request Checks that Operation::CHECKS evaluates from the decoded input. A projection of the IR’s ResourcePermissions and Requirements (docs/permissions.md, sections 6.1 and 6.2); the server runtime’s permissions module enforces them through a service’s Authorizer.
roles
The role registry a generated client publishes (roles::ROLES, docs/roles.md §7 “Clients”), for a console’s role picker. Generated from one rule in every client language: public roles only, in the service’s catalogue order, each with its public permissions only.
split
Writing a structure as a JSON body with its header members taken out, in one pass: the body goes straight to bytes, and each header member becomes header text on the way. A structure with an @httpPayload member writes that member’s bytes as the body instead, raw.
text
Text on the wire: query strings, header lists, percent-encoding.
time
Timestamps. date-time (RFC 3339) is chrono’s own serde form and needs nothing here; the two formats @timestampFormat can choose instead have serde modules generated members name in #[serde(with = ...)].
validate
Constraint checking. Generated Validate impls walk an input and record every violation; a request with any is rejected before an implementation sees it.