1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Common types for XDR (External Data Representation) encoding and decoding.
//!
//! This crate provides length-constrained collection types for XDR serialization:
//! - [`VecM`] - Generic vector with maximum length constraint
//! - [`BytesM`] - Byte vector with maximum length constraint
//! - [`StringM`] - String (as bytes) with maximum length constraint
//!
//! # Features
//!
//! - **`alloc`** - Enables heap allocation support (required for most functionality)
//! - **`std`** - Enables standard library support (implies `alloc`)
//! - **`serde`** - Enables serde serialization/deserialization (implies `alloc`)
//! - **`schemars`** - Enables JSON Schema generation via schemars (implies `alloc`)
//!
//! # no_std Support
//!
//! This crate is `no_std` by default. Enable the `alloc` feature for heap-allocated
//! collections, or `std` for full standard library support.
//!
//! # Examples
//!
//! ```ignore
//! use xdr_common::{VecM, BytesM, StringM};
//!
//! // Create a vector with max length of 10
//! let v: VecM<u32, 10> = vec![1, 2, 3].try_into()?;
//!
//! // Create a byte array with max length of 100
//! let b: BytesM<100> = b"hello".as_slice().try_into()?;
//!
//! // Create a string with max length of 50
//! let s: StringM<50> = "world".try_into()?;
//! ```
extern crate alloc;
pub use ;
pub use *;
/// The maximum number of bytes a decoder will preallocate for a
/// variable-length collection before reading its elements.
///
/// Decoded lengths are untrusted, so capacity reservations are capped at
/// this many bytes to prevent memory-exhaustion attacks from maliciously
/// large length prefixes; collections grow normally beyond it.
pub const MAX_PREALLOC_BYTES: usize = 0x1_0000;
pub use *;
pub use *;
pub use *;