Skip to main content

rusty_rtos_mqtt_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![forbid(unsafe_code)]
3//! `rusty_rtos_mqtt-core` — the pure heart of `rusty_rtos_mqtt`.
4//!
5//! Rules this crate lives by (from the Kairos mission plan):
6//!
7//! 1. `no_std` by default; `alloc` is a feature, never an assumption.
8//! 2. No CPU, no registers, no allocator, no operating system. Ports and
9//!    backends are separate WRAP crates.
10//! 3. Every type that crosses to another Kairos package comes from
11//!    `rusty_rtos_core`, so packages compose without conversions.
12//! 4. Handles are indices, never pointers; nothing on a hot path allocates.
13//! 5. `forbid(unsafe)`. The C kernel's trace is the oracle; the scalar path
14//!    is the oracle; any faster path is gated identical against it.
15
16#[cfg(feature = "alloc")]
17extern crate alloc;
18
19pub use rusty_rtos_core as rtos_core;
20
21/// The names a firmware wants in scope.
22pub mod prelude {
23    pub use rusty_rtos_core::prelude::*;
24}
25
26/// Crate version, for manifests and logs.
27pub const VERSION: &str = env!("CARGO_PKG_VERSION");
28
29/// `core_mqtt_state.c`: the QoS publish state machine.
30pub mod state;
31
32/// The MQTT fixed header: a packet type, and a variable-byte length.
33pub mod header;
34
35/// The MQTT 5 property primitives: bounded reads out of a packet.
36pub mod property;
37
38/// The fixed header of every outgoing MQTT packet.
39pub mod writer;
40
41/// How big an outgoing packet will be.
42pub mod size;
43
44/// Reading an acknowledgement off the wire.
45pub mod ack;
46
47/// Reading the CONNACK, which sets every limit the session then runs under.
48pub mod connack;
49
50/// Reading an incoming PUBLISH, the packet that carries application data.
51pub mod publish;
52
53/// The DISCONNECT, which in MQTT 5 travels both ways.
54pub mod disconnect;
55
56/// Building a CONNECT, the packet that starts a session.
57pub mod connect;
58
59/// Building an outgoing PUBLISH: three serializers, one packet.
60pub mod outpublish;
61
62/// The rest of what a client sends: SUBSCRIBE, UNSUBSCRIBE, acks and PINGREQ.
63pub mod outbound;
64
65/// Pulling a packet's header off a transport, one byte at a time.
66pub mod reader;
67
68/// Which property may go in which outgoing packet: six tables, swept.
69pub mod validate;
70
71/// Every limit a session runs under, and where each one came from.
72pub mod context;
73
74/// The buffer an outgoing property section is written into.
75pub mod builder;
76
77/// Walking a property section back, one property at a time.
78pub mod cursor;
79
80/// Does this topic name match that topic filter?
81pub mod topic;
82
83/// The client context, and what it refuses before it sends anything.
84pub mod client;
85
86/// Opening a connection: CONNECT, CONNACK and what a resumed session owes.
87pub mod session;
88
89/// The receive loop and the acknowledgements that come out of it.
90pub mod loop_;
91
92pub use ack::{
93    AckError, AckInfo, Limits, PINGRESP_REMAINING_LENGTH, PUBREL, PacketInfo, deserialize_ack,
94};
95pub use builder::{BuilderError, PropertyBuilder, allowed_properties};
96pub use client::{
97    ClientError, ConnectionStatus, MqttContext, RetainHandling as SubscribeRetainHandling,
98    Subscription as ClientSubscription, SubscriptionType,
99};
100pub use connack::{
101    CONNACK_MINIMUM_SIZE, ClientSettings, ConnAck, ConnAckError, SESSION_PRESENT_MASK,
102    ServerSettings, deserialize_connack,
103};
104pub use connect::{
105    CONNECT_HEADER_SIZE, Connect, ConnectError, ConnectSize, Will, connect_packet_size,
106    serialize_connect,
107};
108pub use context::{
109    ClientLimits, ConnectionProperties, ContextError, MAX_PACKET_SIZE, ServerLimits,
110    update_with_connect_props,
111};
112pub use cursor::{CursorError, PropertyCursor, Width, width_of};
113pub use disconnect::{
114    Disconnect, DisconnectError, DisconnectSize, deserialize_disconnect, disconnect_packet_size,
115    reason_code_allowed, serialize_disconnect, validate_outgoing_properties,
116};
117pub use header::{
118    HeaderError, MAX_REMAINING_LENGTH, PacketHeader, REMAINING_LENGTH_INVALID,
119    encode_variable_length, incoming_packet_valid, process_incoming_packet_type_and_length,
120    variable_length_encoded_size,
121};
122pub use outbound::{
123    OutboundError, RetainHandling, Subscription, ack_reason_code_allowed, serialize_ack,
124    serialize_pingreq, serialize_subscribe, serialize_unsubscribe, subscription_options,
125};
126pub use outpublish::{
127    OutgoingError, OutgoingPublish, PublishSize, publish_packet_size, serialize_publish,
128    serialize_publish_header, serialize_publish_header_without_topic, update_duplicate_flag,
129};
130pub use property::{PropertyError, PropertyReader, decode_variable_length, encode_string};
131pub use publish::{PublishError, PublishInfo, deserialize_publish};
132pub use reader::{IncomingHeader, ReadError, Received, Sent, Transport, read_header};
133pub use size::{
134    ListPacket, PINGREQ_PACKET_SIZE, PacketSize, SizeError, ack_packet_size, list_packet_size,
135    subscribe_packet_size, unsubscribe_packet_size,
136};
137pub use state::{
138    AckType, Cursor, Operation, PACKET_ID_INVALID, PublishRecords, PublishState, QoS, Record,
139    StateError, calculate_state_ack, calculate_state_publish,
140};
141pub use topic::{
142    TopicError, matches, packet_type_name, status_name, suback_status_codes, unsuback_status_codes,
143};
144pub use validate::{
145    ConnectValidation, ValidateError, validate_connect_properties, validate_publish_ack_properties,
146    validate_publish_params, validate_publish_properties, validate_subscribe_properties,
147    validate_unsubscribe_properties, validate_will_properties,
148};
149pub use writer::{
150    ConnectInfo, PINGREQ, VERSION_5, WillInfo, serialize_ack_fixed, serialize_connect_fixed_header,
151    serialize_disconnect_fixed, serialize_subscribe_header, serialize_unsubscribe_header,
152};