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};
37pub use limits::Limits;
38pub use packed::{Packed, PackedElement};
39
40/// Sparse request or reply around a scalar, result, or other inline payload.
41#[derive(Debug, PartialEq, Eq, Wire)]
42#[wire(crate = "crate")]
43pub struct Message<T>(pub T);
44
45/// Published Serde bulk byte types; ByteArray includes a length prefix, unlike
46/// an ordinary `[u8; N]`. Changing field representation requires consumer review.
47pub use serde_bytes::{ByteArray, ByteBuf};
48
49#[cfg(test)]
50mod tests;