Skip to main content

Crate asyncapi_rust_models

Crate asyncapi_rust_models 

Source
Expand description

Runtime data structures for AsyncAPI 3.0 specifications

This crate provides Rust types that represent AsyncAPI 3.0 specification objects. These types are used by the proc macros to generate specifications at compile time and can also be constructed manually.

§Overview

The main types mirror the AsyncAPI 3.0 specification structure:

§Serialization

All types implement serde::Serialize and serde::Deserialize for JSON serialization, following the AsyncAPI 3.0 specification’s JSON Schema.

§Example

use asyncapi_rust_models::*;
use indexmap::IndexMap;

// Create a simple AsyncAPI specification
let spec = AsyncApiSpec {
    asyncapi: "3.0.0".to_string(),
    info: Info {
        title: "My API".to_string(),
        version: "1.0.0".to_string(),
        description: Some("A simple API".to_string()),
    },
    servers: None,
    channels: None,
    operations: None,
    components: None,
};

// Serialize to JSON
let json = serde_json::to_string_pretty(&spec).unwrap();

Structs§

AsyncApiSpec
AsyncAPI 3.0 Specification
Channel
Communication channel
ChannelRef
Reference to a channel
Components
Reusable components
Info
API information object
Message
Message definition
MessageBindings
Protocol specific message bindings
MqttLastWill
Mqtt last will structure
MqttMessageBindings
Mqtt message bindings
MqttOperationBindings
Mqtt operation bindings
MqttServerBindings
Mqtt server binding
Operation
Operation (send or receive)
OperationBindings
Protocol specific operation bindings
Parameter
Channel parameter definition
SchemaObject
Schema object with all JSON Schema properties
Server
Server connection information
ServerBindings
Protocol specific server bindings
ServerVariable
Server variable definition

Enums§

MessageRef
Reference to a message definition
MqttBindingNumValue
Represents mqtt binding properties which can be either a number or a json schema like sessionExpiryInterval or maximumPacketSize
MqttResponseTopic
Mqtt response topic
OperationAction
Operation action type
Schema
JSON Schema object