Expand description
§odp-core
Transport-independent protocol primitives for the Offering Discovery Protocol.
This crate owns ODP wire models, validation, Resource Identity and reference handling, pagination models, and protocol-level errors. It does not depend on an asynchronous runtime, HTTP client, Directory behavior, Agent orchestration, or a Service framework.
Normative JSON Schemas are embedded in the crate and compiled without network access. Parsing a wire document performs JSON Schema validation, typed deserialization, and the semantic checks that cannot be expressed by JSON Schema alone.
use odp_core::parse_service_document;
let data = br#"{
"description": "An AI-enabled plant store.",
"http": { "endpoint_base": "/odp" },
"language": "en",
"localizations": ["en"],
"name": "Indica Flowers",
"odp_version": "1.0",
"operations": [
{ "authentication": "not-required", "name": "get-offering" },
{ "authentication": "not-required", "name": "list-offerings" }
]
}"#;
let document = parse_service_document(data)?;
assert_eq!(document.name, "Indica Flowers");Validation failures retain structured paths and schema keywords so applications can present more than a generic parse failure:
use odp_core::{ParseError, parse_service_document};
let error = parse_service_document(br#"{}"#).unwrap_err();
if let ParseError::Validation(validation) = error {
for issue in validation.issues {
println!("{}: {}", issue.path, issue.message);
}
}Resource identifiers are local to a Service. Compose a stable identity with the canonical Service origin, and resolve origin-relative resource links against that same origin:
use odp_core::{ResourceIdentity, ResourceType, resolve_resource_reference};
let identity = ResourceIdentity::new(
"https://shop.example/.well-known/odp",
ResourceType::Offering,
"rubber-plant",
)?;
let image = resolve_resource_reference("/images/rubber-plant.webp", &identity.service)?;
assert_eq!(identity.service, "https://shop.example");
assert_eq!(image.as_str(), "https://shop.example/images/rubber-plant.webp");Unknown additive members are retained in each model’s additional map. Use
parse_problem_response for an ODP error response when the HTTP status must agree with the Problem
Details body.
See the workspace guide and the ODP specification.
Structs§
- Action
- Action
Request - Capability
Link - Collection
- Collection
Search Request - Enrollment
Protocol - Filter
Capability Source - Filter
Definition - Filter
Expression - Filter
Unit - Http
Action Target - Http
Configuration - Invalid
Parameter - McpEndpoint
- Offering
- Offering
Page - Offering
Search Request - Open
ApiAction Target - Operation
Descriptor - Page
- Payment
Protocol - Price
Preview - Problem
Details - Refinement
Bucket - Refinement
Group - Resource
Identity - Resource
Image - Schema
Reference - Search
Capabilities - Service
Branding - Service
Branding Image - Service
Document - Service
Open Api - Service
Protocols - Sort
Capability Source - Sort
Definition - SortKey
- Validation
Error - Validation
Issue
Enums§
- Action
Relation - Authentication
Requirement - Filter
Operator - Filter
Type - McpEndpoint
Type - Missing
Placement - Operation
- Parse
Error - Payment
Option - Price
Type - Protocol
- Reference
Error - Representation
- Resource
Image Type - Resource
Type - Service
Branding Image Type - Sort
Direction
Constants§
Functions§
- build_
operation_ url - derive_
service_ origin - is_
local_ resource_ identifier - operation_
method - parse_
collection - parse_
collection_ search_ request - parse_
filter_ definition - parse_
filter_ definition_ page - parse_
offering - parse_
offering_ search_ request - parse_
offering_ search_ response - parse_
page - parse_
problem_ details - parse_
problem_ response - parse_
resource_ identity - parse_
service_ document - parse_
sort_ definition - parse_
sort_ definition_ page - resolve_
continuation - resolve_
resource_ reference - validate_
value