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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Writing XDR values to a serialization format without runtime checks.
//!
//! This module defines the [`WriterUnchecked`] trait, the infallible, unsafe
//! counterpart to [`Writer`](crate::serialize::writer::Writer). Its methods
//! perform no runtime bounds checking: the caller must guarantee up front
//! that the writer's underlying buffer is large enough for everything
//! written, typically by sizing it with the worst-case bounds computed by
//! `#[derive(ConstXDRSize)]` (`cxs::ConstMaxSize` / `txs::ConstMaxSize`).
//!
//! Preconditions are checked with `debug_assert!` only, so misuse is caught
//! in debug builds at zero release-mode cost. This is intended for
//! code-size-sensitive targets (e.g. wasm or rv32 guest programs) where the
//! `WriteResult` plumbing and per-write bounds checks of
//! [`Writer`](crate::serialize::writer::Writer) are unwanted overhead.
/// Something that can write XDR values to a serialization format, without
/// runtime checks.
///
/// This is the infallible, unsafe counterpart to
/// [`Writer`](crate::serialize::writer::Writer): the same primitive-writing
/// methods, but no method can fail and no method checks that space remains
/// in the underlying buffer.
///
/// # Safety
///
/// Every method shares one contract: the writer's underlying buffer must
/// have enough space remaining for the encoded form of the argument. The
/// opaque methods additionally require `bytes.len() <= u32::MAX`.
/// Violations are `debug_assert!`ed; in release builds they are undefined
/// behavior.