mars-protocol · types
Public declarations and documentation for mars-protocol::types.
Package: mars-protocol · Workspace version: 0.1.0 · Module: types
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
types::SemanticAnnotation
RDF-style semantic annotation attached to a MARS entry.
Annotations express facts about an entry in predicate-object form. At least
one of object_literal or object_uri must be provided; supplying both is
valid and indicates the literal is a label/display form of the referenced
resource.
Serialization
All fields use camelCase when serialized to JSON.
Examples
use mars_protocol::types::SemanticAnnotation;
let ann = SemanticAnnotation {
predicate_uri: "https://schema.org/author".into(),
object_literal: Some("Ada Lovelace".into()),
object_uri: Some("did:oas:hmr:abc123".into()),
};
assert!(ann.validate().is_ok());#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct SemanticAnnotation {
/// The predicate URI identifying the relationship (e.g. `https://schema.org/author`).
pub predicate_uri: String,
/// A literal value for the object (plain text, number-as-string, etc.).
#[serde(skip_serializing_if = "Option::is_none")]
pub object_literal: Option<String>,
/// A URI reference for the object (another DID, schema URL, etc.).
#[serde(skip_serializing_if = "Option::is_none")]
pub object_uri: Option<String>
}Source line: 43.
types::SemanticAnnotation::validate
Validates the annotation.
Rules
predicate_urimust be non-empty.- At least one of
object_literalorobject_urimust beSome. - If
object_literalisSome, it must be non-empty. - If
object_uriisSome, it must be non-empty.
Errors
Returns [MarsError::ValidationError] describing the first violated rule.
pub fn validate(&self) -> Result<(), MarsError>;Source line: 69.
types::ServiceEndpoint
A service endpoint declared in a MARS entry.
Per the MARS/OpenAgent Endpoint Contract (v1.0.0), each endpoint declares
a transport type, a URL, and a selection priority. Day-one only https
endpoints are consumed; weave and wss endpoints are stored for
forward compatibility.
Forward Compatibility
Clients MUST ignore endpoint types they do not support. The properties
field provides a transport-specific extension point so future metadata
does not require schema-level changes.
Serialization
All fields use camelCase. properties is omitted when empty/None.
Examples
use mars_protocol::types::ServiceEndpoint;
let ep = ServiceEndpoint {
id: "primary-https".into(),
endpoint_type: "https".into(),
url: "https://api.example.com".into(),
priority: 0,
properties: None,
};
assert!(ep.validate().is_ok());#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct ServiceEndpoint {
/// Unique identifier within a DID's endpoint set.
pub id: String,
/// Transport type: `"https"` (day-one), `"weave"`, `"wss"` (phase-2).
#[serde(rename = "type")]
pub endpoint_type: String,
/// Transport-specific address (URL, peer ID, etc.).
pub url: String,
/// Selection priority. 0 = highest. Lower values preferred.
pub priority: u32,
/// Transport-specific metadata (extensible, optional).
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<serde_json::Map<String, serde_json::Value>>
}Source line: 141.
types::ServiceEndpoint::validate
Validates the endpoint.
Rules
idmust be non-empty.endpoint_typemust be non-empty.urlmust be non-empty.- Unknown
endpoint_typevalues are accepted (forward compat) but known types are validated for URL scheme consistency.
pub fn validate(&self) -> Result<(), MarsError>;Source line: 173.
types::ServiceEndpoint::is_known_type
Returns whether this endpoint type is a known transport.
pub fn is_known_type(&self) -> bool;Source line: 224.
Source provenance
Source: mars-protocol/src/types.rs · SHA-256 72218f99cce9b23c9f242c86610a92ccbba2b529825cd7cd713e344d8445f858. Package overview.