Skip to main content

ic_wire/
lib.rs

1//! Evolvable Wire messages over bounded Serde/Postcard.
2//!
3//! Bounded encoding and decoding, method identity and request-header
4//! admission. Header admission is
5//! neither authentication nor payload/schema/resource validation.
6#![no_std]
7extern crate alloc;
8#[cfg(test)]
9extern crate std;
10
11mod decode;
12mod encode;
13mod error;
14mod fields;
15mod finite;
16mod framing;
17mod limits;
18mod meter;
19mod packed;
20pub mod serde_packed;
21
22/// Sparse extensions, open variants, and explicit message projections.
23pub mod evolution;
24
25/// Optional schema admission and TypeScript declarations.
26#[cfg(feature = "typescript")]
27pub mod typescript;
28
29pub use error::{Error, LimitKind};
30pub use evolution::{Evolving, Method};
31pub use evolution::{decode, encode, encode_into, encode_to_slice, encoded_len};
32pub use fields::{Bytes, BytesRef, List, Text, TextRef};
33pub use finite::{FiniteF32, FiniteF64};
34pub use framing::{Direction, Encoding, method_id, validate_request_header};
35
36pub use ic_wire_derive::{Wire, WireSchema};
37
38/// Attests the ordered (Rust field name, serialized field name) pairs of a
39/// fixed Serde record. Omit fields that are always skipped. Consumers with
40/// custom serializers must qualify this declaration against their actual bytes.
41pub trait WireFieldOrder {
42    /// Fields in positional serialization order.
43    const FIELDS: &'static [(&'static str, &'static str)];
44}
45pub use limits::Limits;
46pub use packed::{Packed, PackedElement};
47
48/// Sparse request or reply around a scalar, result, or other inline payload.
49#[derive(Debug, PartialEq, Eq, Wire)]
50#[wire(crate = "crate")]
51pub struct Message<T>(pub T);
52
53/// Published Serde bulk byte types; ByteArray includes a length prefix, unlike
54/// an ordinary `[u8; N]`. Changing field representation requires consumer review.
55pub use serde_bytes::{ByteArray, ByteBuf};
56
57#[cfg(test)]
58mod tests;