Skip to content

Rust — Core Types

nnrp-core is the canonical Rust source for NNRP/1 Preview4 protocol semantics. It owns wire constants, fixed-layout metadata, profile registries, runtime-control frames, object/cache metadata, validation, and reusable lifecycle state machines.

Dependency

toml
[dependencies]
nnrp-core = "1.0.0-preview.4.0"

Boundary

nnrp-core does not open sockets or spawn async tasks. It defines and validates the protocol model that nnrp-runtime, transport providers, FFI bindings, WASM helpers, and conformance suites reuse.

Main Type Families

FamilyExamplesUsed by
Protocol header and message idscommon header, message type, header flags, protocol versionall wire codecs
Session lifecycleSessionOpenMetadata, SessionCloseMetadata, patch/migrate metadataclient/server runtime
Submit/resultFrameSubmitMetadata, ResultPushMetadata, result-drop metadatarequest/result flow
Flow and schedulingcredit, backpressure, priority, deadline, expire-at metadataruntime control
Runtime controlcancel/abort, progress, partial result, capability, route hint, trace contextPreview4 control profiles
Runtime objectobject declare/ref/release/delta metadataheavy transport and orchestration paths
Cache referencecache reference/miss/invalidate metadatacache-aware profiles and runtimes
Registryprofile ids, schema ids, payload families, object kindsconformance and SDK validation

FrameSubmitMetadata

Field GroupDescription
Profile and schemaSelects which standard or application profile interprets the body.
Operation identityCorrelates submit, result, cancellation, and runtime feedback.
Priority and deadlineProvides scheduling hints without forcing JSON/protobuf control envelopes.
Object/cache hintsAllows transports and runtimes to coordinate large payload references.

ResultPushMetadata

Field GroupDescription
CorrelationTies result bytes back to a submitted frame.
Status and timingCarries completion state and timing hints.
Payload interpretationPoints to the profile/schema used for the result body.

Runtime-Control Metadata

The Rust metadata names mirror the wire profiles documented under Runtime Control Profiles.

Control familyPurpose
Cancel / abortStop expired or obsolete work.
Priority / deadline / expire-atUpdate scheduler decisions after submit.
Progress / partial resultStream meaningful intermediate output.
Backpressure / creditCoordinate producer and consumer pressure.
Capability / route hintExchange costs, preferences, limits, and execution hints.
Trace context / result-drop reasonMake end-to-end timing and dropped work explainable.

Object And Cache Metadata

FamilyPurpose
Object declareIntroduces a runtime object with kind, size, version, and lifetime hints.
Object refRefers to an existing object instead of resending bytes.
Object releaseReleases ownership or lease state.
Object deltaSends compact updates for an existing object.
Cache referenceReports a reusable cached object.
Cache missReports that a requested cache key is unavailable.
Cache invalidateInvalidates stale object/cache state.

Common Pitfalls

WARNING

  1. Do not reassign numeric message, profile, schema, object-kind, or error values in SDK-local code.
  2. Do not put transport behavior in nnrp-core; use nnrp-runtime and provider crates.
  3. Do not tunnel Preview4 control semantics through ad hoc JSON when a compact control frame already exists.

NNRP Documentation