turul-a2a-types
Ergonomic Rust wrappers over the prost-generated A2A Protocol v1.0 types.
Transport- and storage-agnostic — used by both the server framework
(turul-a2a) and the client
library (turul-a2a-client).
Highlights
Task,TaskStatus,TaskStatewith state-machine enforcement.Message,Part,Rolefor conversational payloads.Artifactfor task outputs (text, JSON data, raw bytes, URL).wiremodule: JSON-RPC method constants and SSE event shapes.
All public types are #[non_exhaustive] — new proto fields land as
additive changes, not breaking ones. Raw proto access stays available
via as_proto() / as_proto_mut() / into_proto() as an escape
hatch.
Task lifecycle
use ;
let mut task = new
.with_context_id;
task.set_status;
task.append_artifact;
task.complete; // transitions to TaskState::Completed
The state machine rejects illegal transitions: e.g. you cannot move
from Completed back to Working. TaskState::is_terminal() and
TaskState::can_transition_to(next) are public so callers can check
before mutating.
Messages
use ;
let msg = new;
assert_eq!;
assert_eq!;
Part covers the four A2A part variants:
| Constructor | Variant |
|---|---|
Part::text(s) |
inline text |
Part::data(json_value) |
structured JSON payload |
Part::url(url, media_type) |
reference to external content |
Part::raw(bytes, media_type) |
inline binary |
Helpers (as_text, as_data, as_url, as_raw, parse_data::<T>)
let executors pattern-match on incoming parts without touching proto
types.
Artifacts
use ;
let art = new
.with_name
.with_description;
Task::push_text_artifact(id, name, body) is a one-liner shortcut
when you just want a single text artifact.
Raw proto escape hatch
If you need a field that isn't covered by the wrapper API, drop down to the proto:
let proto: &Task = task.as_proto;
// or to mutate:
let proto_mut: &mut Task = task.as_proto_mut;
Prefer wrapper methods where they exist — the wrappers preserve the state-machine invariants that raw proto access can violate.
See the workspace README for the project overview and crate map.
License
Licensed under either MIT or Apache 2.0 at your option.