zenoh_protocol/lib.rs
1//
2// Copyright (c) 2023 ZettaScale Technology
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7// which is available at https://www.apache.org/licenses/LICENSE-2.0.
8//
9// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10//
11// Contributors:
12// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
13//
14
15//! ⚠️ WARNING ⚠️
16//!
17//! This crate is intended for Zenoh's internal use.
18//!
19//! [Click here for Zenoh's documentation](https://docs.rs/zenoh/latest/zenoh)
20#![cfg_attr(not(feature = "std"), no_std)]
21extern crate alloc;
22
23pub mod common;
24pub mod core;
25pub mod network;
26pub mod scouting;
27pub mod transport;
28pub mod zenoh;
29
30// Zenoh version
31pub const VERSION: u8 = 0x09;
32
33// Zenoh protocol uses the following conventions for message definition and representation.
34//
35//
36// # Single byte field
37//
38// A fixed size field of 8 bits.
39//
40// ```text
41// 7 6 5 4 3 2 1 0
42// +-+-+-+-+-+-+-+-+
43// | u8 |
44// +---------------+
45// ```
46//
47//
48// # Variable length field
49//
50// The field size depends on the element definition and/or actual encoding. An example of variable
51// length element is an array of bytes (e.g., a payload or a string).
52//
53// ```text
54// 7 6 5 4 3 2 1 0
55// +-+-+-+-+-+-+-+-+
56// ~ element ~
57// +---------------+
58// ```
59//
60//
61// # u64 field
62//
63// A u64 is a specialized variable length field that is used to encode an unsigned integer.
64//
65// ```text
66// 7 6 5 4 3 2 1 0
67// +-+-+-+-+-+-+-+-+
68// % u64 %
69// +---------------+
70// ```
71//
72//
73// # Array field
74//
75// An array contains a fixed number of elements whose number is known a priori or indicated by
76// another field. Each element can be either a single byte field or a variable length field.
77//
78// ```text
79// 7 6 5 4 3 2 1 0
80// +-+-+-+-+-+-+-+-+
81// ~ [element] ~
82// +---------------+
83// ```
84//
85//
86// # Vector field
87//
88// A vector contains a variable number of elements and is represented as follows:
89//
90// ```text
91// 7 6 5 4 3 2 1 0
92// +-+-+-+-+-+-+-+-+
93// ~ <element> ~
94// +---------------+
95// ```
96//
97// A vector field is always expanded as follows:
98//
99// ```text
100// 7 6 5 4 3 2 1 0
101// +-+-+-+-+-+-+-+-+
102// % num %
103// +---------------+
104// ~ [element] ~
105// +---------------+
106// ```
107//