1#![allow(
17 clippy::missing_errors_doc,
18 clippy::unreadable_literal,
19 clippy::wildcard_imports
20)]
21
22pub const XDR_FILES_SHA256: [(&str, &str); 13] = [
24 (
25 "xdr/Stellar-SCP.x",
26 "41ff1f6a3de9fcb07372953e73a9e49071e278081e411a62e69683ad3591a218",
27 ),
28 (
29 "xdr/Stellar-contract-config-setting.x",
30 "56eb21162887b96ec423cab36e924ab085d52f885b7d41bcd3cd040e8dfe616d",
31 ),
32 (
33 "xdr/Stellar-contract-env-meta.x",
34 "e1f0595afd6249879ea4898f0ccb2293025c21db3a6590178ba129bc1e99d8c9",
35 ),
36 (
37 "xdr/Stellar-contract-meta.x",
38 "5f2ad607144ef4dcc44c6d4fbf3c10cc07d716e707281a8789fb958c83904e16",
39 ),
40 (
41 "xdr/Stellar-contract-spec.x",
42 "f0655f82e0a28a79e067c02f427cc709db1e4323a50c9b85f730f812b9612dbd",
43 ),
44 (
45 "xdr/Stellar-contract.x",
46 "5d8063e6ddc09be5c22569f1668720b5c705505a70e9224f00748fa58aab2fc5",
47 ),
48 (
49 "xdr/Stellar-exporter.x",
50 "d36ec815cceb534e3f565448aa79ba8dd7f6be6485de050dfb62613eb05b11a4",
51 ),
52 (
53 "xdr/Stellar-internal.x",
54 "81f9804d6a5f88afdb62e8d00506c348e45c7b70012d781d14ef22ddc7414833",
55 ),
56 (
57 "xdr/Stellar-ledger-entries.x",
58 "3e212dab2177c86c0a0a439dd870f4e71dda70472930f17096f48b9507e4ef1a",
59 ),
60 (
61 "xdr/Stellar-ledger.x",
62 "93cdd4dd597d9f0b271762c2f3c81be8562e2004f4f019f539ca7d7e92167099",
63 ),
64 (
65 "xdr/Stellar-overlay.x",
66 "ad2ea6b317d8b0e72bf8b08b6a4b11dc81352afb7bf6409dc4c84e48dd76b092",
67 ),
68 (
69 "xdr/Stellar-transaction.x",
70 "840ee5f5216c8e35ded4590e2976d246fa5f8b4e60670051b8373e7282c20278",
71 ),
72 (
73 "xdr/Stellar-types.x",
74 "1bf41da09307489c04c454d9081a3ddcd52d04ed9af173abeb308fe4907dc590",
75 ),
76];
77
78use core::{array::TryFromSliceError, fmt, fmt::Debug, marker::Sized, ops::Deref, slice};
79
80#[cfg(feature = "std")]
81use core::marker::PhantomData;
82
83#[cfg(not(feature = "alloc"))]
85mod noalloc {
86 pub mod boxed {
87 pub type Box<T> = &'static T;
88 }
89 pub mod vec {
90 pub type Vec<T> = &'static [T];
91 }
92}
93#[cfg(not(feature = "alloc"))]
94use noalloc::{boxed::Box, vec::Vec};
95
96#[cfg(all(not(feature = "std"), feature = "alloc"))]
99extern crate alloc;
100#[cfg(all(not(feature = "std"), feature = "alloc"))]
101use alloc::{
102 borrow::ToOwned,
103 boxed::Box,
104 string::{FromUtf8Error, String},
105 vec::Vec,
106};
107#[cfg(feature = "std")]
108use std::string::FromUtf8Error;
109
110#[cfg(feature = "arbitrary")]
111use arbitrary::Arbitrary;
112
113#[cfg(all(feature = "schemars", feature = "alloc", not(feature = "std")))]
114use alloc::borrow::Cow;
115#[cfg(all(feature = "schemars", feature = "alloc", feature = "std"))]
116use std::borrow::Cow;
117
118#[cfg(feature = "std")]
121use std::{
122 error, io,
123 io::{BufRead, BufReader, Cursor, Read, Write},
124};
125
126#[derive(Debug)]
130pub enum Error {
131 Invalid,
132 Unsupported,
133 LengthExceedsMax,
134 LengthMismatch,
135 NonZeroPadding,
136 Utf8Error(core::str::Utf8Error),
137 #[cfg(feature = "alloc")]
138 InvalidHex,
139 #[cfg(feature = "std")]
140 Io(io::Error),
141 DepthLimitExceeded,
142 #[cfg(feature = "serde_json")]
143 Json(serde_json::Error),
144 LengthLimitExceeded,
145 #[cfg(feature = "arbitrary")]
146 Arbitrary(arbitrary::Error),
147}
148
149impl PartialEq for Error {
150 fn eq(&self, other: &Self) -> bool {
151 match (self, other) {
152 (Self::Invalid, Self::Invalid)
153 | (Self::Unsupported, Self::Unsupported)
154 | (Self::LengthExceedsMax, Self::LengthExceedsMax)
155 | (Self::LengthMismatch, Self::LengthMismatch)
156 | (Self::NonZeroPadding, Self::NonZeroPadding) => true,
157
158 (Self::Utf8Error(l), Self::Utf8Error(r)) => l == r,
159
160 #[cfg(feature = "alloc")]
161 (Self::InvalidHex, Self::InvalidHex) => true,
162
163 #[cfg(feature = "std")]
170 (Self::Io(l), Self::Io(r)) => l.kind() == r.kind(),
171
172 (Self::DepthLimitExceeded, Self::DepthLimitExceeded) => true,
173
174 #[cfg(feature = "serde_json")]
175 (Self::Json(l), Self::Json(r)) => l.classify() == r.classify(),
176
177 (Self::LengthLimitExceeded, Self::LengthLimitExceeded) => true,
178
179 #[cfg(feature = "arbitrary")]
180 (Self::Arbitrary(l), Self::Arbitrary(r)) => l == r,
181
182 _ => false,
183 }
184 }
185}
186
187#[cfg(feature = "std")]
188impl error::Error for Error {
189 #[must_use]
190 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
191 match self {
192 Error::Invalid
193 | Error::Unsupported
194 | Error::LengthExceedsMax
195 | Error::LengthMismatch
196 | Error::NonZeroPadding => None,
197
198 Error::Utf8Error(e) => Some(e),
199
200 Self::InvalidHex => None,
201
202 Self::Io(e) => Some(e),
203
204 Self::DepthLimitExceeded => None,
205
206 #[cfg(feature = "serde_json")]
207 Self::Json(e) => Some(e),
208
209 Self::LengthLimitExceeded => None,
210
211 #[cfg(feature = "arbitrary")]
212 Self::Arbitrary(e) => Some(e),
213 }
214 }
215}
216
217impl fmt::Display for Error {
218 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
219 match self {
220 Error::Invalid => write!(f, "xdr value invalid"),
221 Error::Unsupported => write!(f, "xdr value unsupported"),
222 Error::LengthExceedsMax => write!(f, "xdr value max length exceeded"),
223 Error::LengthMismatch => write!(f, "xdr value length does not match"),
224 Error::NonZeroPadding => write!(f, "xdr padding contains non-zero bytes"),
225 Error::Utf8Error(e) => write!(f, "{e}"),
226
227 #[cfg(feature = "alloc")]
228 Error::InvalidHex => write!(f, "hex invalid"),
229
230 #[cfg(feature = "std")]
231 Error::Io(e) => write!(f, "{e}"),
232
233 Error::DepthLimitExceeded => write!(f, "depth limit exceeded"),
234
235 #[cfg(feature = "serde_json")]
236 Error::Json(e) => write!(f, "{e}"),
237
238 Error::LengthLimitExceeded => write!(f, "length limit exceeded"),
239
240 #[cfg(feature = "arbitrary")]
241 Error::Arbitrary(e) => write!(f, "{e}"),
242 }
243 }
244}
245
246impl From<TryFromSliceError> for Error {
247 fn from(_: TryFromSliceError) -> Error {
248 Error::LengthMismatch
249 }
250}
251
252impl From<core::str::Utf8Error> for Error {
253 #[must_use]
254 fn from(e: core::str::Utf8Error) -> Self {
255 Error::Utf8Error(e)
256 }
257}
258
259#[cfg(feature = "alloc")]
260impl From<FromUtf8Error> for Error {
261 #[must_use]
262 fn from(e: FromUtf8Error) -> Self {
263 Error::Utf8Error(e.utf8_error())
264 }
265}
266
267#[cfg(feature = "std")]
268impl From<io::Error> for Error {
269 #[must_use]
270 fn from(e: io::Error) -> Self {
271 Error::Io(e)
272 }
273}
274
275#[cfg(feature = "serde_json")]
276impl From<serde_json::Error> for Error {
277 #[must_use]
278 fn from(e: serde_json::Error) -> Self {
279 Error::Json(e)
280 }
281}
282
283#[cfg(feature = "arbitrary")]
284impl From<arbitrary::Error> for Error {
285 #[must_use]
286 fn from(e: arbitrary::Error) -> Self {
287 Error::Arbitrary(e)
288 }
289}
290
291impl From<Error> for () {
292 fn from(_: Error) {}
293}
294
295pub trait Name {
299 fn name(&self) -> &'static str;
300}
301
302pub trait Discriminant<D> {
306 fn discriminant(&self) -> D;
307}
308
309pub trait Variants<V> {
311 fn variants() -> slice::Iter<'static, V>
312 where
313 V: Sized;
314}
315
316pub trait Enum: Name + Variants<Self> + Sized {}
318
319pub trait Union<D>: Name + Discriminant<D> + Variants<D>
321where
322 D: Sized,
323{
324}
325
326#[cfg(feature = "std")]
329#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
330pub struct Limits {
331 pub depth: u32,
340
341 pub len: usize,
343}
344
345#[cfg(feature = "std")]
346impl Limits {
347 #[must_use]
348 pub fn none() -> Self {
349 Self {
350 depth: u32::MAX,
351 len: usize::MAX,
352 }
353 }
354
355 #[must_use]
356 pub fn depth(depth: u32) -> Self {
357 Limits {
358 depth,
359 ..Limits::none()
360 }
361 }
362
363 #[must_use]
364 pub fn len(len: usize) -> Self {
365 Limits {
366 len,
367 ..Limits::none()
368 }
369 }
370}
371
372#[cfg(feature = "std")]
377pub struct Limited<L> {
378 pub inner: L,
379 pub(crate) limits: Limits,
380}
381
382#[cfg(feature = "std")]
383impl<L> Limited<L> {
384 pub fn new(inner: L, limits: Limits) -> Self {
389 Limited { inner, limits }
390 }
391
392 pub(crate) fn consume_len(&mut self, len: usize) -> Result<(), Error> {
399 if let Some(len) = self.limits.len.checked_sub(len) {
400 self.limits.len = len;
401 Ok(())
402 } else {
403 Err(Error::LengthLimitExceeded)
404 }
405 }
406
407 pub(crate) fn with_limited_depth<T, F>(&mut self, f: F) -> Result<T, Error>
413 where
414 F: FnOnce(&mut Self) -> Result<T, Error>,
415 {
416 if let Some(depth) = self.limits.depth.checked_sub(1) {
417 self.limits.depth = depth;
418 let res = f(self);
419 self.limits.depth = self.limits.depth.saturating_add(1);
420 res
421 } else {
422 Err(Error::DepthLimitExceeded)
423 }
424 }
425}
426
427#[cfg(feature = "std")]
428impl<R: Read> Read for Limited<R> {
429 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
431 self.inner.read(buf)
432 }
433}
434
435#[cfg(feature = "std")]
436impl<R: BufRead> BufRead for Limited<R> {
437 fn fill_buf(&mut self) -> std::io::Result<&[u8]> {
439 self.inner.fill_buf()
440 }
441
442 fn consume(&mut self, amt: usize) {
444 self.inner.consume(amt);
445 }
446}
447
448#[cfg(feature = "std")]
449impl<W: Write> Write for Limited<W> {
450 fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
452 self.inner.write(buf)
453 }
454
455 fn flush(&mut self) -> std::io::Result<()> {
457 self.inner.flush()
458 }
459}
460
461#[cfg(feature = "std")]
462pub struct ReadXdrIter<R: Read, S: ReadXdr> {
463 reader: Limited<BufReader<R>>,
464 _s: PhantomData<S>,
465}
466
467#[cfg(feature = "std")]
468impl<R: Read, S: ReadXdr> ReadXdrIter<R, S> {
469 fn new(r: R, limits: Limits) -> Self {
470 Self {
471 reader: Limited {
472 inner: BufReader::new(r),
473 limits,
474 },
475 _s: PhantomData,
476 }
477 }
478}
479
480#[cfg(feature = "std")]
481impl<R: Read, S: ReadXdr> Iterator for ReadXdrIter<R, S> {
482 type Item = Result<S, Error>;
483
484 fn next(&mut self) -> Option<Self::Item> {
492 match self.reader.fill_buf() {
499 Ok([]) => return None,
502 Err(e) => return Some(Err(Error::Io(e))),
504 Ok([..]) => (),
506 };
507 let r = self.reader.with_limited_depth(|dlr| S::read_xdr(dlr));
509 match r {
510 Ok(s) => Some(Ok(s)),
511 Err(e) => Some(Err(e)),
512 }
513 }
514}
515
516pub trait ReadXdr
517where
518 Self: Sized,
519{
520 #[cfg(feature = "std")]
535 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error>;
536
537 #[cfg(feature = "base64")]
542 fn read_xdr_base64<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
543 let mut dec = Limited::new(
544 base64::read::DecoderReader::new(
545 SkipWhitespace::new(&mut r.inner),
546 &base64::engine::general_purpose::STANDARD,
547 ),
548 r.limits.clone(),
549 );
550 let t = Self::read_xdr(&mut dec)?;
551 Ok(t)
552 }
553
554 #[cfg(feature = "std")]
573 fn read_xdr_to_end<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
574 let s = Self::read_xdr(r)?;
575 if r.read(&mut [0u8; 1])? == 0 {
578 Ok(s)
579 } else {
580 Err(Error::Invalid)
581 }
582 }
583
584 #[cfg(feature = "base64")]
589 fn read_xdr_base64_to_end<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
590 let mut dec = Limited::new(
591 base64::read::DecoderReader::new(
592 SkipWhitespace::new(&mut r.inner),
593 &base64::engine::general_purpose::STANDARD,
594 ),
595 r.limits.clone(),
596 );
597 let t = Self::read_xdr_to_end(&mut dec)?;
598 Ok(t)
599 }
600
601 #[cfg(feature = "std")]
616 fn read_xdr_into<R: Read>(&mut self, r: &mut Limited<R>) -> Result<(), Error> {
617 *self = Self::read_xdr(r)?;
618 Ok(())
619 }
620
621 #[cfg(feature = "std")]
640 fn read_xdr_into_to_end<R: Read>(&mut self, r: &mut Limited<R>) -> Result<(), Error> {
641 Self::read_xdr_into(self, r)?;
642 if r.read(&mut [0u8; 1])? == 0 {
645 Ok(())
646 } else {
647 Err(Error::Invalid)
648 }
649 }
650
651 #[cfg(feature = "std")]
670 fn read_xdr_iter<R: Read>(r: &mut Limited<R>) -> ReadXdrIter<&mut R, Self> {
671 ReadXdrIter::new(&mut r.inner, r.limits.clone())
672 }
673
674 #[cfg(feature = "base64")]
677 fn read_xdr_base64_iter<R: Read>(
678 r: &mut Limited<R>,
679 ) -> ReadXdrIter<
680 base64::read::DecoderReader<
681 '_,
682 base64::engine::general_purpose::GeneralPurpose,
683 SkipWhitespace<&mut R>,
684 >,
685 Self,
686 > {
687 let dec = base64::read::DecoderReader::new(
688 SkipWhitespace::new(&mut r.inner),
689 &base64::engine::general_purpose::STANDARD,
690 );
691 ReadXdrIter::new(dec, r.limits.clone())
692 }
693
694 #[cfg(feature = "std")]
699 fn from_xdr(bytes: impl AsRef<[u8]>, limits: Limits) -> Result<Self, Error> {
700 let mut cursor = Limited::new(Cursor::new(bytes.as_ref()), limits);
701 let t = Self::read_xdr_to_end(&mut cursor)?;
702 Ok(t)
703 }
704
705 #[cfg(feature = "base64")]
710 fn from_xdr_base64(b64: impl AsRef<[u8]>, limits: Limits) -> Result<Self, Error> {
711 let b64_reader = Cursor::new(b64);
712 let mut dec = Limited::new(
713 base64::read::DecoderReader::new(
714 SkipWhitespace::new(b64_reader),
715 &base64::engine::general_purpose::STANDARD,
716 ),
717 limits,
718 );
719 let t = Self::read_xdr_to_end(&mut dec)?;
720 Ok(t)
721 }
722}
723
724pub trait WriteXdr {
725 #[cfg(feature = "std")]
726 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error>;
727
728 #[cfg(feature = "std")]
729 fn to_xdr(&self, limits: Limits) -> Result<Vec<u8>, Error> {
730 let mut cursor = Limited::new(Cursor::new(vec![]), limits);
731 self.write_xdr(&mut cursor)?;
732 let bytes = cursor.inner.into_inner();
733 Ok(bytes)
734 }
735
736 #[cfg(feature = "base64")]
737 fn to_xdr_base64(&self, limits: Limits) -> Result<String, Error> {
738 let mut enc = Limited::new(
739 base64::write::EncoderStringWriter::new(&base64::engine::general_purpose::STANDARD),
740 limits,
741 );
742 self.write_xdr(&mut enc)?;
743 let b64 = enc.inner.into_inner();
744 Ok(b64)
745 }
746}
747
748#[cfg(feature = "std")]
751fn pad_len(len: usize) -> usize {
752 (4 - (len % 4)) % 4
753}
754
755impl ReadXdr for i32 {
756 #[cfg(feature = "std")]
757 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
758 let mut b = [0u8; 4];
759 r.with_limited_depth(|r| {
760 r.consume_len(b.len())?;
761 r.read_exact(&mut b)?;
762 Ok(i32::from_be_bytes(b))
763 })
764 }
765}
766
767impl WriteXdr for i32 {
768 #[cfg(feature = "std")]
769 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
770 let b: [u8; 4] = self.to_be_bytes();
771 w.with_limited_depth(|w| {
772 w.consume_len(b.len())?;
773 Ok(w.write_all(&b)?)
774 })
775 }
776}
777
778impl ReadXdr for u32 {
779 #[cfg(feature = "std")]
780 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
781 let mut b = [0u8; 4];
782 r.with_limited_depth(|r| {
783 r.consume_len(b.len())?;
784 r.read_exact(&mut b)?;
785 Ok(u32::from_be_bytes(b))
786 })
787 }
788}
789
790impl WriteXdr for u32 {
791 #[cfg(feature = "std")]
792 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
793 let b: [u8; 4] = self.to_be_bytes();
794 w.with_limited_depth(|w| {
795 w.consume_len(b.len())?;
796 Ok(w.write_all(&b)?)
797 })
798 }
799}
800
801impl ReadXdr for i64 {
802 #[cfg(feature = "std")]
803 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
804 let mut b = [0u8; 8];
805 r.with_limited_depth(|r| {
806 r.consume_len(b.len())?;
807 r.read_exact(&mut b)?;
808 Ok(i64::from_be_bytes(b))
809 })
810 }
811}
812
813impl WriteXdr for i64 {
814 #[cfg(feature = "std")]
815 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
816 let b: [u8; 8] = self.to_be_bytes();
817 w.with_limited_depth(|w| {
818 w.consume_len(b.len())?;
819 Ok(w.write_all(&b)?)
820 })
821 }
822}
823
824impl ReadXdr for u64 {
825 #[cfg(feature = "std")]
826 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
827 let mut b = [0u8; 8];
828 r.with_limited_depth(|r| {
829 r.consume_len(b.len())?;
830 r.read_exact(&mut b)?;
831 Ok(u64::from_be_bytes(b))
832 })
833 }
834}
835
836impl WriteXdr for u64 {
837 #[cfg(feature = "std")]
838 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
839 let b: [u8; 8] = self.to_be_bytes();
840 w.with_limited_depth(|w| {
841 w.consume_len(b.len())?;
842 Ok(w.write_all(&b)?)
843 })
844 }
845}
846
847impl ReadXdr for f32 {
848 #[cfg(feature = "std")]
849 fn read_xdr<R: Read>(_r: &mut Limited<R>) -> Result<Self, Error> {
850 todo!()
851 }
852}
853
854impl WriteXdr for f32 {
855 #[cfg(feature = "std")]
856 fn write_xdr<W: Write>(&self, _w: &mut Limited<W>) -> Result<(), Error> {
857 todo!()
858 }
859}
860
861impl ReadXdr for f64 {
862 #[cfg(feature = "std")]
863 fn read_xdr<R: Read>(_r: &mut Limited<R>) -> Result<Self, Error> {
864 todo!()
865 }
866}
867
868impl WriteXdr for f64 {
869 #[cfg(feature = "std")]
870 fn write_xdr<W: Write>(&self, _w: &mut Limited<W>) -> Result<(), Error> {
871 todo!()
872 }
873}
874
875impl ReadXdr for bool {
876 #[cfg(feature = "std")]
877 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
878 r.with_limited_depth(|r| {
879 let i = u32::read_xdr(r)?;
880 let b = i == 1;
881 Ok(b)
882 })
883 }
884}
885
886impl WriteXdr for bool {
887 #[cfg(feature = "std")]
888 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
889 w.with_limited_depth(|w| {
890 let i = u32::from(*self); i.write_xdr(w)
892 })
893 }
894}
895
896impl<T: ReadXdr> ReadXdr for Option<T> {
897 #[cfg(feature = "std")]
898 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
899 r.with_limited_depth(|r| {
900 let i = u32::read_xdr(r)?;
901 match i {
902 0 => Ok(None),
903 1 => {
904 let t = T::read_xdr(r)?;
905 Ok(Some(t))
906 }
907 _ => Err(Error::Invalid),
908 }
909 })
910 }
911}
912
913impl<T: WriteXdr> WriteXdr for Option<T> {
914 #[cfg(feature = "std")]
915 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
916 w.with_limited_depth(|w| {
917 if let Some(t) = self {
918 1u32.write_xdr(w)?;
919 t.write_xdr(w)?;
920 } else {
921 0u32.write_xdr(w)?;
922 }
923 Ok(())
924 })
925 }
926}
927
928impl<T: ReadXdr> ReadXdr for Box<T> {
929 #[cfg(feature = "std")]
930 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
931 r.with_limited_depth(|r| Ok(Box::new(T::read_xdr(r)?)))
932 }
933}
934
935impl<T: WriteXdr> WriteXdr for Box<T> {
936 #[cfg(feature = "std")]
937 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
938 w.with_limited_depth(|w| T::write_xdr(self, w))
939 }
940}
941
942impl ReadXdr for () {
943 #[cfg(feature = "std")]
944 fn read_xdr<R: Read>(_r: &mut Limited<R>) -> Result<Self, Error> {
945 Ok(())
946 }
947}
948
949impl WriteXdr for () {
950 #[cfg(feature = "std")]
951 fn write_xdr<W: Write>(&self, _w: &mut Limited<W>) -> Result<(), Error> {
952 Ok(())
953 }
954}
955
956impl<const N: usize> ReadXdr for [u8; N] {
957 #[cfg(feature = "std")]
958 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
959 r.with_limited_depth(|r| {
960 r.consume_len(N)?;
961 let padding = pad_len(N);
962 r.consume_len(padding)?;
963 let mut arr = [0u8; N];
964 r.read_exact(&mut arr)?;
965 let pad = &mut [0u8; 3][..padding];
966 r.read_exact(pad)?;
967 if pad.iter().any(|b| *b != 0) {
968 return Err(Error::NonZeroPadding);
969 }
970 Ok(arr)
971 })
972 }
973}
974
975impl<const N: usize> WriteXdr for [u8; N] {
976 #[cfg(feature = "std")]
977 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
978 w.with_limited_depth(|w| {
979 w.consume_len(N)?;
980 let padding = pad_len(N);
981 w.consume_len(padding)?;
982 w.write_all(self)?;
983 w.write_all(&[0u8; 3][..padding])?;
984 Ok(())
985 })
986 }
987}
988
989impl<T: ReadXdr, const N: usize> ReadXdr for [T; N] {
990 #[cfg(feature = "std")]
991 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
992 r.with_limited_depth(|r| {
993 let mut vec = Vec::with_capacity(N);
994 for _ in 0..N {
995 let t = T::read_xdr(r)?;
996 vec.push(t);
997 }
998 let arr: [T; N] = vec.try_into().unwrap_or_else(|_: Vec<T>| unreachable!());
999 Ok(arr)
1000 })
1001 }
1002}
1003
1004impl<T: WriteXdr, const N: usize> WriteXdr for [T; N] {
1005 #[cfg(feature = "std")]
1006 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
1007 w.with_limited_depth(|w| {
1008 for t in self {
1009 t.write_xdr(w)?;
1010 }
1011 Ok(())
1012 })
1013 }
1014}
1015
1016#[cfg(feature = "alloc")]
1019#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1020#[cfg_attr(
1021 feature = "serde",
1022 serde_with::serde_as,
1023 derive(serde::Serialize, serde::Deserialize)
1024)]
1025#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1026pub struct VecM<T, const MAX: u32 = { u32::MAX }>(Vec<T>);
1027
1028#[cfg(not(feature = "alloc"))]
1029#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1030#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1031pub struct VecM<T, const MAX: u32 = { u32::MAX }>(Vec<T>)
1032where
1033 T: 'static;
1034
1035impl<T, const MAX: u32> Deref for VecM<T, MAX> {
1036 type Target = Vec<T>;
1037
1038 fn deref(&self) -> &Self::Target {
1039 &self.0
1040 }
1041}
1042
1043impl<T, const MAX: u32> Default for VecM<T, MAX> {
1044 fn default() -> Self {
1045 Self(Vec::default())
1046 }
1047}
1048
1049#[cfg(feature = "schemars")]
1050impl<T: schemars::JsonSchema, const MAX: u32> schemars::JsonSchema for VecM<T, MAX> {
1051 fn schema_name() -> String {
1052 format!("VecM<{}, {}>", T::schema_name(), MAX)
1053 }
1054
1055 fn is_referenceable() -> bool {
1056 false
1057 }
1058
1059 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1060 let schema = Vec::<T>::json_schema(gen);
1061 if let schemars::schema::Schema::Object(mut schema) = schema {
1062 if let Some(array) = schema.array.clone() {
1063 schema.array = Some(Box::new(schemars::schema::ArrayValidation {
1064 max_items: Some(MAX),
1065 ..*array
1066 }));
1067 }
1068 schema.into()
1069 } else {
1070 schema
1071 }
1072 }
1073}
1074
1075#[cfg(feature = "schemars")]
1076impl<T, TA, const MAX: u32> serde_with::schemars_0_8::JsonSchemaAs<VecM<T, MAX>> for VecM<TA, MAX>
1077where
1078 TA: serde_with::schemars_0_8::JsonSchemaAs<T>,
1079{
1080 fn schema_name() -> String {
1081 <VecM<serde_with::Schema<T, TA>, MAX> as schemars::JsonSchema>::schema_name()
1082 }
1083
1084 fn schema_id() -> Cow<'static, str> {
1085 <VecM<serde_with::Schema<T, TA>, MAX> as schemars::JsonSchema>::schema_id()
1086 }
1087
1088 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1089 <VecM<serde_with::Schema<T, TA>, MAX> as schemars::JsonSchema>::json_schema(gen)
1090 }
1091
1092 fn is_referenceable() -> bool {
1093 <VecM<serde_with::Schema<T, TA>, MAX> as schemars::JsonSchema>::is_referenceable()
1094 }
1095}
1096
1097#[cfg(feature = "serde")]
1098impl<T, U, const MAX: u32> serde_with::SerializeAs<VecM<T, MAX>> for VecM<U, MAX>
1099where
1100 U: serde_with::SerializeAs<T>,
1101{
1102 fn serialize_as<S>(source: &VecM<T, MAX>, serializer: S) -> Result<S::Ok, S::Error>
1103 where
1104 S: serde::Serializer,
1105 {
1106 serializer.collect_seq(
1107 source
1108 .iter()
1109 .map(|item| serde_with::ser::SerializeAsWrap::<T, U>::new(item)),
1110 )
1111 }
1112}
1113
1114#[cfg(feature = "serde")]
1115impl<'de, T, U, const MAX: u32> serde_with::DeserializeAs<'de, VecM<T, MAX>> for VecM<U, MAX>
1116where
1117 U: serde_with::DeserializeAs<'de, T>,
1118{
1119 fn deserialize_as<D>(deserializer: D) -> Result<VecM<T, MAX>, D::Error>
1120 where
1121 D: serde::Deserializer<'de>,
1122 {
1123 let vec = <Vec<U> as serde_with::DeserializeAs<Vec<T>>>::deserialize_as(deserializer)?;
1124 vec.try_into().map_err(serde::de::Error::custom)
1125 }
1126}
1127
1128impl<T, const MAX: u32> VecM<T, MAX> {
1129 pub const MAX_LEN: usize = { MAX as usize };
1130
1131 #[must_use]
1132 #[allow(clippy::unused_self)]
1133 pub fn max_len(&self) -> usize {
1134 Self::MAX_LEN
1135 }
1136
1137 #[must_use]
1138 pub fn as_vec(&self) -> &Vec<T> {
1139 self.as_ref()
1140 }
1141}
1142
1143#[cfg(feature = "alloc")]
1144impl<T, const MAX: u32> VecM<T, MAX> {
1145 pub fn iter_mut(&mut self) -> core::slice::IterMut<'_, T> {
1146 self.0.iter_mut()
1147 }
1148}
1149
1150#[cfg(feature = "alloc")]
1151impl<'a, T, const MAX: u32> core::iter::IntoIterator for &'a mut VecM<T, MAX> {
1152 type Item = &'a mut T;
1153 type IntoIter = core::slice::IterMut<'a, T>;
1154 fn into_iter(self) -> Self::IntoIter {
1155 self.iter_mut()
1156 }
1157}
1158
1159#[cfg(feature = "alloc")]
1160impl<T, const MAX: u32> core::iter::IntoIterator for VecM<T, MAX> {
1161 type Item = T;
1162 type IntoIter = <Vec<T> as IntoIterator>::IntoIter;
1163 fn into_iter(self) -> Self::IntoIter {
1164 self.0.into_iter()
1165 }
1166}
1167
1168impl<'a, T, const MAX: u32> core::iter::IntoIterator for &'a VecM<T, MAX> {
1169 type Item = &'a T;
1170 type IntoIter = core::slice::Iter<'a, T>;
1171 fn into_iter(self) -> Self::IntoIter {
1172 self.iter()
1173 }
1174}
1175
1176impl<T: Clone, const MAX: u32> VecM<T, MAX> {
1177 #[must_use]
1178 #[cfg(feature = "alloc")]
1179 pub fn to_vec(&self) -> Vec<T> {
1180 self.into()
1181 }
1182
1183 #[must_use]
1184 pub fn into_vec(self) -> Vec<T> {
1185 self.into()
1186 }
1187}
1188
1189impl<const MAX: u32> VecM<u8, MAX> {
1190 #[cfg(feature = "alloc")]
1191 pub fn to_string(&self) -> Result<String, Error> {
1192 self.try_into()
1193 }
1194
1195 #[cfg(feature = "alloc")]
1196 pub fn into_string(self) -> Result<String, Error> {
1197 self.try_into()
1198 }
1199
1200 #[cfg(feature = "alloc")]
1201 #[must_use]
1202 pub fn to_string_lossy(&self) -> String {
1203 String::from_utf8_lossy(&self.0).into_owned()
1204 }
1205
1206 #[cfg(feature = "alloc")]
1207 #[must_use]
1208 pub fn into_string_lossy(self) -> String {
1209 String::from_utf8_lossy(&self.0).into_owned()
1210 }
1211}
1212
1213impl<T: Clone> VecM<T, 1> {
1214 #[must_use]
1215 pub fn to_option(&self) -> Option<T> {
1216 if self.len() > 0 {
1217 Some(self.0[0].clone())
1218 } else {
1219 None
1220 }
1221 }
1222}
1223
1224#[cfg(not(feature = "alloc"))]
1225impl<T: Clone> From<VecM<T, 1>> for Option<T> {
1226 #[must_use]
1227 fn from(v: VecM<T, 1>) -> Self {
1228 v.to_option()
1229 }
1230}
1231
1232#[cfg(feature = "alloc")]
1233impl<T> VecM<T, 1> {
1234 #[must_use]
1235 pub fn into_option(mut self) -> Option<T> {
1236 self.0.drain(..).next()
1237 }
1238}
1239
1240#[cfg(feature = "alloc")]
1241impl<T> From<VecM<T, 1>> for Option<T> {
1242 #[must_use]
1243 fn from(v: VecM<T, 1>) -> Self {
1244 v.into_option()
1245 }
1246}
1247
1248impl<T, const MAX: u32> TryFrom<Vec<T>> for VecM<T, MAX> {
1249 type Error = Error;
1250
1251 fn try_from(v: Vec<T>) -> Result<Self, Error> {
1252 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1253 if len <= MAX {
1254 Ok(VecM(v))
1255 } else {
1256 Err(Error::LengthExceedsMax)
1257 }
1258 }
1259}
1260
1261impl<T, const MAX: u32> From<VecM<T, MAX>> for Vec<T> {
1262 #[must_use]
1263 fn from(v: VecM<T, MAX>) -> Self {
1264 v.0
1265 }
1266}
1267
1268#[cfg(feature = "alloc")]
1269impl<T: Clone, const MAX: u32> From<&VecM<T, MAX>> for Vec<T> {
1270 #[must_use]
1271 fn from(v: &VecM<T, MAX>) -> Self {
1272 v.0.clone()
1273 }
1274}
1275
1276impl<T, const MAX: u32> AsRef<Vec<T>> for VecM<T, MAX> {
1277 #[must_use]
1278 fn as_ref(&self) -> &Vec<T> {
1279 &self.0
1280 }
1281}
1282
1283#[cfg(feature = "alloc")]
1284impl<T: Clone, const MAX: u32> TryFrom<&Vec<T>> for VecM<T, MAX> {
1285 type Error = Error;
1286
1287 fn try_from(v: &Vec<T>) -> Result<Self, Error> {
1288 v.as_slice().try_into()
1289 }
1290}
1291
1292#[cfg(feature = "alloc")]
1293impl<T: Clone, const MAX: u32> TryFrom<&[T]> for VecM<T, MAX> {
1294 type Error = Error;
1295
1296 fn try_from(v: &[T]) -> Result<Self, Error> {
1297 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1298 if len <= MAX {
1299 Ok(VecM(v.to_vec()))
1300 } else {
1301 Err(Error::LengthExceedsMax)
1302 }
1303 }
1304}
1305
1306impl<T, const MAX: u32> AsRef<[T]> for VecM<T, MAX> {
1307 #[cfg(feature = "alloc")]
1308 #[must_use]
1309 fn as_ref(&self) -> &[T] {
1310 self.0.as_ref()
1311 }
1312 #[cfg(not(feature = "alloc"))]
1313 #[must_use]
1314 fn as_ref(&self) -> &[T] {
1315 self.0
1316 }
1317}
1318
1319#[cfg(feature = "alloc")]
1320impl<T: Clone, const N: usize, const MAX: u32> TryFrom<[T; N]> for VecM<T, MAX> {
1321 type Error = Error;
1322
1323 fn try_from(v: [T; N]) -> Result<Self, Error> {
1324 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1325 if len <= MAX {
1326 Ok(VecM(v.to_vec()))
1327 } else {
1328 Err(Error::LengthExceedsMax)
1329 }
1330 }
1331}
1332
1333#[cfg(feature = "alloc")]
1334impl<T: Clone, const N: usize, const MAX: u32> TryFrom<VecM<T, MAX>> for [T; N] {
1335 type Error = VecM<T, MAX>;
1336
1337 fn try_from(v: VecM<T, MAX>) -> core::result::Result<Self, Self::Error> {
1338 let s: [T; N] = v.0.try_into().map_err(|v: Vec<T>| VecM::<T, MAX>(v))?;
1339 Ok(s)
1340 }
1341}
1342
1343#[cfg(feature = "alloc")]
1344impl<T: Clone, const N: usize, const MAX: u32> TryFrom<&[T; N]> for VecM<T, MAX> {
1345 type Error = Error;
1346
1347 fn try_from(v: &[T; N]) -> Result<Self, Error> {
1348 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1349 if len <= MAX {
1350 Ok(VecM(v.to_vec()))
1351 } else {
1352 Err(Error::LengthExceedsMax)
1353 }
1354 }
1355}
1356
1357#[cfg(not(feature = "alloc"))]
1358impl<T: Clone, const N: usize, const MAX: u32> TryFrom<&'static [T; N]> for VecM<T, MAX> {
1359 type Error = Error;
1360
1361 fn try_from(v: &'static [T; N]) -> Result<Self, Error> {
1362 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1363 if len <= MAX {
1364 Ok(VecM(v))
1365 } else {
1366 Err(Error::LengthExceedsMax)
1367 }
1368 }
1369}
1370
1371#[cfg(feature = "alloc")]
1372impl<const MAX: u32> TryFrom<&String> for VecM<u8, MAX> {
1373 type Error = Error;
1374
1375 fn try_from(v: &String) -> Result<Self, Error> {
1376 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1377 if len <= MAX {
1378 Ok(VecM(v.as_bytes().to_vec()))
1379 } else {
1380 Err(Error::LengthExceedsMax)
1381 }
1382 }
1383}
1384
1385#[cfg(feature = "alloc")]
1386impl<const MAX: u32> TryFrom<String> for VecM<u8, MAX> {
1387 type Error = Error;
1388
1389 fn try_from(v: String) -> Result<Self, Error> {
1390 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1391 if len <= MAX {
1392 Ok(VecM(v.into()))
1393 } else {
1394 Err(Error::LengthExceedsMax)
1395 }
1396 }
1397}
1398
1399#[cfg(feature = "alloc")]
1400impl<const MAX: u32> TryFrom<VecM<u8, MAX>> for String {
1401 type Error = Error;
1402
1403 fn try_from(v: VecM<u8, MAX>) -> Result<Self, Error> {
1404 Ok(String::from_utf8(v.0)?)
1405 }
1406}
1407
1408#[cfg(feature = "alloc")]
1409impl<const MAX: u32> TryFrom<&VecM<u8, MAX>> for String {
1410 type Error = Error;
1411
1412 fn try_from(v: &VecM<u8, MAX>) -> Result<Self, Error> {
1413 Ok(core::str::from_utf8(v.as_ref())?.to_owned())
1414 }
1415}
1416
1417#[cfg(feature = "alloc")]
1418impl<const MAX: u32> TryFrom<&str> for VecM<u8, MAX> {
1419 type Error = Error;
1420
1421 fn try_from(v: &str) -> Result<Self, Error> {
1422 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1423 if len <= MAX {
1424 Ok(VecM(v.into()))
1425 } else {
1426 Err(Error::LengthExceedsMax)
1427 }
1428 }
1429}
1430
1431#[cfg(not(feature = "alloc"))]
1432impl<const MAX: u32> TryFrom<&'static str> for VecM<u8, MAX> {
1433 type Error = Error;
1434
1435 fn try_from(v: &'static str) -> Result<Self, Error> {
1436 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1437 if len <= MAX {
1438 Ok(VecM(v.as_bytes()))
1439 } else {
1440 Err(Error::LengthExceedsMax)
1441 }
1442 }
1443}
1444
1445impl<'a, const MAX: u32> TryFrom<&'a VecM<u8, MAX>> for &'a str {
1446 type Error = Error;
1447
1448 fn try_from(v: &'a VecM<u8, MAX>) -> Result<Self, Error> {
1449 Ok(core::str::from_utf8(v.as_ref())?)
1450 }
1451}
1452
1453impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
1454 #[cfg(feature = "std")]
1455 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
1456 r.with_limited_depth(|r| {
1457 let len: u32 = u32::read_xdr(r)?;
1458 if len > MAX {
1459 return Err(Error::LengthExceedsMax);
1460 }
1461
1462 r.consume_len(len as usize)?;
1463 let padding = pad_len(len as usize);
1464 r.consume_len(padding)?;
1465
1466 let mut vec = vec![0u8; len as usize];
1467 r.read_exact(&mut vec)?;
1468
1469 let pad = &mut [0u8; 3][..padding];
1470 r.read_exact(pad)?;
1471 if pad.iter().any(|b| *b != 0) {
1472 return Err(Error::NonZeroPadding);
1473 }
1474
1475 Ok(VecM(vec))
1476 })
1477 }
1478}
1479
1480impl<const MAX: u32> WriteXdr for VecM<u8, MAX> {
1481 #[cfg(feature = "std")]
1482 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
1483 w.with_limited_depth(|w| {
1484 let len: u32 = self.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1485 len.write_xdr(w)?;
1486
1487 w.consume_len(self.len())?;
1488 let padding = pad_len(self.len());
1489 w.consume_len(padding)?;
1490
1491 w.write_all(&self.0)?;
1492
1493 w.write_all(&[0u8; 3][..padding])?;
1494
1495 Ok(())
1496 })
1497 }
1498}
1499
1500impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
1501 #[cfg(feature = "std")]
1502 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
1503 r.with_limited_depth(|r| {
1504 let len = u32::read_xdr(r)?;
1505 if len > MAX {
1506 return Err(Error::LengthExceedsMax);
1507 }
1508
1509 let mut vec = Vec::new();
1510 for _ in 0..len {
1511 let t = T::read_xdr(r)?;
1512 vec.push(t);
1513 }
1514
1515 Ok(VecM(vec))
1516 })
1517 }
1518}
1519
1520impl<T: WriteXdr, const MAX: u32> WriteXdr for VecM<T, MAX> {
1521 #[cfg(feature = "std")]
1522 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
1523 w.with_limited_depth(|w| {
1524 let len: u32 = self.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1525 len.write_xdr(w)?;
1526
1527 for t in &self.0 {
1528 t.write_xdr(w)?;
1529 }
1530
1531 Ok(())
1532 })
1533 }
1534}
1535
1536#[cfg(feature = "alloc")]
1539#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1540#[cfg_attr(
1541 feature = "serde",
1542 derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr)
1543)]
1544#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1545pub struct BytesM<const MAX: u32 = { u32::MAX }>(Vec<u8>);
1546
1547#[cfg(not(feature = "alloc"))]
1548#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1549#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1550pub struct BytesM<const MAX: u32 = { u32::MAX }>(Vec<u8>);
1551
1552impl<const MAX: u32> core::fmt::Display for BytesM<MAX> {
1553 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1554 #[cfg(feature = "alloc")]
1555 let v = &self.0;
1556 #[cfg(not(feature = "alloc"))]
1557 let v = self.0;
1558 for b in v {
1559 write!(f, "{b:02x}")?;
1560 }
1561 Ok(())
1562 }
1563}
1564
1565impl<const MAX: u32> core::fmt::Debug for BytesM<MAX> {
1566 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1567 #[cfg(feature = "alloc")]
1568 let v = &self.0;
1569 #[cfg(not(feature = "alloc"))]
1570 let v = self.0;
1571 write!(f, "BytesM(")?;
1572 for b in v {
1573 write!(f, "{b:02x}")?;
1574 }
1575 write!(f, ")")?;
1576 Ok(())
1577 }
1578}
1579
1580#[cfg(feature = "alloc")]
1581impl<const MAX: u32> core::str::FromStr for BytesM<MAX> {
1582 type Err = Error;
1583 fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
1584 hex::decode(s).map_err(|_| Error::InvalidHex)?.try_into()
1585 }
1586}
1587
1588impl<const MAX: u32> Deref for BytesM<MAX> {
1589 type Target = Vec<u8>;
1590
1591 fn deref(&self) -> &Self::Target {
1592 &self.0
1593 }
1594}
1595
1596#[cfg(feature = "schemars")]
1597impl<const MAX: u32> schemars::JsonSchema for BytesM<MAX> {
1598 fn schema_name() -> String {
1599 format!("BytesM<{MAX}>")
1600 }
1601
1602 fn is_referenceable() -> bool {
1603 false
1604 }
1605
1606 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
1607 let schema = String::json_schema(gen);
1608 if let schemars::schema::Schema::Object(mut schema) = schema {
1609 schema.extensions.insert(
1610 "contentEncoding".to_owned(),
1611 serde_json::Value::String("hex".to_string()),
1612 );
1613 schema.extensions.insert(
1614 "contentMediaType".to_owned(),
1615 serde_json::Value::String("application/binary".to_string()),
1616 );
1617 let string = *schema.string.unwrap_or_default().clone();
1618 schema.string = Some(Box::new(schemars::schema::StringValidation {
1619 max_length: MAX.checked_mul(2).map(Some).unwrap_or_default(),
1620 min_length: None,
1621 ..string
1622 }));
1623 schema.into()
1624 } else {
1625 schema
1626 }
1627 }
1628}
1629
1630impl<const MAX: u32> Default for BytesM<MAX> {
1631 fn default() -> Self {
1632 Self(Vec::default())
1633 }
1634}
1635
1636impl<const MAX: u32> BytesM<MAX> {
1637 pub const MAX_LEN: usize = { MAX as usize };
1638
1639 #[must_use]
1640 #[allow(clippy::unused_self)]
1641 pub fn max_len(&self) -> usize {
1642 Self::MAX_LEN
1643 }
1644
1645 #[must_use]
1646 pub fn as_vec(&self) -> &Vec<u8> {
1647 self.as_ref()
1648 }
1649}
1650
1651impl<const MAX: u32> BytesM<MAX> {
1652 #[must_use]
1653 #[cfg(feature = "alloc")]
1654 pub fn to_vec(&self) -> Vec<u8> {
1655 self.into()
1656 }
1657
1658 #[must_use]
1659 pub fn into_vec(self) -> Vec<u8> {
1660 self.into()
1661 }
1662}
1663
1664impl<const MAX: u32> BytesM<MAX> {
1665 #[cfg(feature = "alloc")]
1666 pub fn to_string(&self) -> Result<String, Error> {
1667 self.try_into()
1668 }
1669
1670 #[cfg(feature = "alloc")]
1671 pub fn into_string(self) -> Result<String, Error> {
1672 self.try_into()
1673 }
1674
1675 #[cfg(feature = "alloc")]
1676 #[must_use]
1677 pub fn to_string_lossy(&self) -> String {
1678 String::from_utf8_lossy(&self.0).into_owned()
1679 }
1680
1681 #[cfg(feature = "alloc")]
1682 #[must_use]
1683 pub fn into_string_lossy(self) -> String {
1684 String::from_utf8_lossy(&self.0).into_owned()
1685 }
1686}
1687
1688impl<const MAX: u32> TryFrom<Vec<u8>> for BytesM<MAX> {
1689 type Error = Error;
1690
1691 fn try_from(v: Vec<u8>) -> Result<Self, Error> {
1692 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1693 if len <= MAX {
1694 Ok(BytesM(v))
1695 } else {
1696 Err(Error::LengthExceedsMax)
1697 }
1698 }
1699}
1700
1701impl<const MAX: u32> From<BytesM<MAX>> for Vec<u8> {
1702 #[must_use]
1703 fn from(v: BytesM<MAX>) -> Self {
1704 v.0
1705 }
1706}
1707
1708#[cfg(feature = "alloc")]
1709impl<const MAX: u32> From<&BytesM<MAX>> for Vec<u8> {
1710 #[must_use]
1711 fn from(v: &BytesM<MAX>) -> Self {
1712 v.0.clone()
1713 }
1714}
1715
1716impl<const MAX: u32> AsRef<Vec<u8>> for BytesM<MAX> {
1717 #[must_use]
1718 fn as_ref(&self) -> &Vec<u8> {
1719 &self.0
1720 }
1721}
1722
1723#[cfg(feature = "alloc")]
1724impl<const MAX: u32> TryFrom<&Vec<u8>> for BytesM<MAX> {
1725 type Error = Error;
1726
1727 fn try_from(v: &Vec<u8>) -> Result<Self, Error> {
1728 v.as_slice().try_into()
1729 }
1730}
1731
1732#[cfg(feature = "alloc")]
1733impl<const MAX: u32> TryFrom<&[u8]> for BytesM<MAX> {
1734 type Error = Error;
1735
1736 fn try_from(v: &[u8]) -> Result<Self, Error> {
1737 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1738 if len <= MAX {
1739 Ok(BytesM(v.to_vec()))
1740 } else {
1741 Err(Error::LengthExceedsMax)
1742 }
1743 }
1744}
1745
1746impl<const MAX: u32> AsRef<[u8]> for BytesM<MAX> {
1747 #[cfg(feature = "alloc")]
1748 #[must_use]
1749 fn as_ref(&self) -> &[u8] {
1750 self.0.as_ref()
1751 }
1752 #[cfg(not(feature = "alloc"))]
1753 #[must_use]
1754 fn as_ref(&self) -> &[u8] {
1755 self.0
1756 }
1757}
1758
1759#[cfg(feature = "alloc")]
1760impl<const N: usize, const MAX: u32> TryFrom<[u8; N]> for BytesM<MAX> {
1761 type Error = Error;
1762
1763 fn try_from(v: [u8; N]) -> Result<Self, Error> {
1764 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1765 if len <= MAX {
1766 Ok(BytesM(v.to_vec()))
1767 } else {
1768 Err(Error::LengthExceedsMax)
1769 }
1770 }
1771}
1772
1773#[cfg(feature = "alloc")]
1774impl<const N: usize, const MAX: u32> TryFrom<BytesM<MAX>> for [u8; N] {
1775 type Error = BytesM<MAX>;
1776
1777 fn try_from(v: BytesM<MAX>) -> core::result::Result<Self, Self::Error> {
1778 let s: [u8; N] = v.0.try_into().map_err(BytesM::<MAX>)?;
1779 Ok(s)
1780 }
1781}
1782
1783#[cfg(feature = "alloc")]
1784impl<const N: usize, const MAX: u32> TryFrom<&[u8; N]> for BytesM<MAX> {
1785 type Error = Error;
1786
1787 fn try_from(v: &[u8; N]) -> Result<Self, Error> {
1788 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1789 if len <= MAX {
1790 Ok(BytesM(v.to_vec()))
1791 } else {
1792 Err(Error::LengthExceedsMax)
1793 }
1794 }
1795}
1796
1797#[cfg(not(feature = "alloc"))]
1798impl<const N: usize, const MAX: u32> TryFrom<&'static [u8; N]> for BytesM<MAX> {
1799 type Error = Error;
1800
1801 fn try_from(v: &'static [u8; N]) -> Result<Self, Error> {
1802 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1803 if len <= MAX {
1804 Ok(BytesM(v))
1805 } else {
1806 Err(Error::LengthExceedsMax)
1807 }
1808 }
1809}
1810
1811#[cfg(feature = "alloc")]
1812impl<const MAX: u32> TryFrom<&String> for BytesM<MAX> {
1813 type Error = Error;
1814
1815 fn try_from(v: &String) -> Result<Self, Error> {
1816 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1817 if len <= MAX {
1818 Ok(BytesM(v.as_bytes().to_vec()))
1819 } else {
1820 Err(Error::LengthExceedsMax)
1821 }
1822 }
1823}
1824
1825#[cfg(feature = "alloc")]
1826impl<const MAX: u32> TryFrom<String> for BytesM<MAX> {
1827 type Error = Error;
1828
1829 fn try_from(v: String) -> Result<Self, Error> {
1830 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1831 if len <= MAX {
1832 Ok(BytesM(v.into()))
1833 } else {
1834 Err(Error::LengthExceedsMax)
1835 }
1836 }
1837}
1838
1839#[cfg(feature = "alloc")]
1840impl<const MAX: u32> TryFrom<BytesM<MAX>> for String {
1841 type Error = Error;
1842
1843 fn try_from(v: BytesM<MAX>) -> Result<Self, Error> {
1844 Ok(String::from_utf8(v.0)?)
1845 }
1846}
1847
1848#[cfg(feature = "alloc")]
1849impl<const MAX: u32> TryFrom<&BytesM<MAX>> for String {
1850 type Error = Error;
1851
1852 fn try_from(v: &BytesM<MAX>) -> Result<Self, Error> {
1853 Ok(core::str::from_utf8(v.as_ref())?.to_owned())
1854 }
1855}
1856
1857#[cfg(feature = "alloc")]
1858impl<const MAX: u32> TryFrom<&str> for BytesM<MAX> {
1859 type Error = Error;
1860
1861 fn try_from(v: &str) -> Result<Self, Error> {
1862 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1863 if len <= MAX {
1864 Ok(BytesM(v.into()))
1865 } else {
1866 Err(Error::LengthExceedsMax)
1867 }
1868 }
1869}
1870
1871#[cfg(not(feature = "alloc"))]
1872impl<const MAX: u32> TryFrom<&'static str> for BytesM<MAX> {
1873 type Error = Error;
1874
1875 fn try_from(v: &'static str) -> Result<Self, Error> {
1876 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1877 if len <= MAX {
1878 Ok(BytesM(v.as_bytes()))
1879 } else {
1880 Err(Error::LengthExceedsMax)
1881 }
1882 }
1883}
1884
1885impl<'a, const MAX: u32> TryFrom<&'a BytesM<MAX>> for &'a str {
1886 type Error = Error;
1887
1888 fn try_from(v: &'a BytesM<MAX>) -> Result<Self, Error> {
1889 Ok(core::str::from_utf8(v.as_ref())?)
1890 }
1891}
1892
1893impl<const MAX: u32> ReadXdr for BytesM<MAX> {
1894 #[cfg(feature = "std")]
1895 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
1896 r.with_limited_depth(|r| {
1897 let len: u32 = u32::read_xdr(r)?;
1898 if len > MAX {
1899 return Err(Error::LengthExceedsMax);
1900 }
1901
1902 r.consume_len(len as usize)?;
1903 let padding = pad_len(len as usize);
1904 r.consume_len(padding)?;
1905
1906 let mut vec = vec![0u8; len as usize];
1907 r.read_exact(&mut vec)?;
1908
1909 let pad = &mut [0u8; 3][..padding];
1910 r.read_exact(pad)?;
1911 if pad.iter().any(|b| *b != 0) {
1912 return Err(Error::NonZeroPadding);
1913 }
1914
1915 Ok(BytesM(vec))
1916 })
1917 }
1918}
1919
1920impl<const MAX: u32> WriteXdr for BytesM<MAX> {
1921 #[cfg(feature = "std")]
1922 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
1923 w.with_limited_depth(|w| {
1924 let len: u32 = self.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
1925 len.write_xdr(w)?;
1926
1927 w.consume_len(self.len())?;
1928 let padding = pad_len(self.len());
1929 w.consume_len(padding)?;
1930
1931 w.write_all(&self.0)?;
1932
1933 w.write_all(&[0u8; 3][..pad_len(len as usize)])?;
1934
1935 Ok(())
1936 })
1937 }
1938}
1939
1940#[cfg(feature = "alloc")]
1954#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1955#[cfg_attr(
1956 feature = "serde",
1957 derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr)
1958)]
1959#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1960pub struct StringM<const MAX: u32 = { u32::MAX }>(Vec<u8>);
1961
1962#[cfg(not(feature = "alloc"))]
1963#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
1964#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
1965pub struct StringM<const MAX: u32 = { u32::MAX }>(Vec<u8>);
1966
1967impl<const MAX: u32> core::fmt::Display for StringM<MAX> {
1968 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1969 #[cfg(feature = "alloc")]
1970 let v = &self.0;
1971 #[cfg(not(feature = "alloc"))]
1972 let v = self.0;
1973 for b in escape_bytes::Escape::new(v) {
1974 write!(f, "{}", b as char)?;
1975 }
1976 Ok(())
1977 }
1978}
1979
1980impl<const MAX: u32> core::fmt::Debug for StringM<MAX> {
1981 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1982 #[cfg(feature = "alloc")]
1983 let v = &self.0;
1984 #[cfg(not(feature = "alloc"))]
1985 let v = self.0;
1986 write!(f, "StringM(")?;
1987 for b in escape_bytes::Escape::new(v) {
1988 write!(f, "{}", b as char)?;
1989 }
1990 write!(f, ")")?;
1991 Ok(())
1992 }
1993}
1994
1995#[cfg(feature = "alloc")]
1996impl<const MAX: u32> core::str::FromStr for StringM<MAX> {
1997 type Err = Error;
1998 fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
1999 let b = escape_bytes::unescape(s.as_bytes()).map_err(|_| Error::Invalid)?;
2000 b.try_into()
2001 }
2002}
2003
2004impl<const MAX: u32> Deref for StringM<MAX> {
2005 type Target = Vec<u8>;
2006
2007 fn deref(&self) -> &Self::Target {
2008 &self.0
2009 }
2010}
2011
2012impl<const MAX: u32> Default for StringM<MAX> {
2013 fn default() -> Self {
2014 Self(Vec::default())
2015 }
2016}
2017
2018#[cfg(feature = "schemars")]
2019impl<const MAX: u32> schemars::JsonSchema for StringM<MAX> {
2020 fn schema_name() -> String {
2021 format!("StringM<{MAX}>")
2022 }
2023
2024 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
2025 let schema = String::json_schema(gen);
2026 if let schemars::schema::Schema::Object(mut schema) = schema {
2027 let string = *schema.string.unwrap_or_default().clone();
2028 schema.string = Some(Box::new(schemars::schema::StringValidation {
2029 max_length: Some(MAX),
2030 ..string
2031 }));
2032 schema.into()
2033 } else {
2034 schema
2035 }
2036 }
2037}
2038
2039impl<const MAX: u32> StringM<MAX> {
2040 pub const MAX_LEN: usize = { MAX as usize };
2041
2042 #[must_use]
2043 #[allow(clippy::unused_self)]
2044 pub fn max_len(&self) -> usize {
2045 Self::MAX_LEN
2046 }
2047
2048 #[must_use]
2049 pub fn as_vec(&self) -> &Vec<u8> {
2050 self.as_ref()
2051 }
2052}
2053
2054impl<const MAX: u32> StringM<MAX> {
2055 #[must_use]
2056 #[cfg(feature = "alloc")]
2057 pub fn to_vec(&self) -> Vec<u8> {
2058 self.into()
2059 }
2060
2061 #[must_use]
2062 pub fn into_vec(self) -> Vec<u8> {
2063 self.into()
2064 }
2065}
2066
2067impl<const MAX: u32> StringM<MAX> {
2068 #[cfg(feature = "alloc")]
2069 pub fn to_utf8_string(&self) -> Result<String, Error> {
2070 self.try_into()
2071 }
2072
2073 #[cfg(feature = "alloc")]
2074 pub fn into_utf8_string(self) -> Result<String, Error> {
2075 self.try_into()
2076 }
2077
2078 #[cfg(feature = "alloc")]
2079 #[must_use]
2080 pub fn to_utf8_string_lossy(&self) -> String {
2081 String::from_utf8_lossy(&self.0).into_owned()
2082 }
2083
2084 #[cfg(feature = "alloc")]
2085 #[must_use]
2086 pub fn into_utf8_string_lossy(self) -> String {
2087 String::from_utf8_lossy(&self.0).into_owned()
2088 }
2089}
2090
2091impl<const MAX: u32> TryFrom<Vec<u8>> for StringM<MAX> {
2092 type Error = Error;
2093
2094 fn try_from(v: Vec<u8>) -> Result<Self, Error> {
2095 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2096 if len <= MAX {
2097 Ok(StringM(v))
2098 } else {
2099 Err(Error::LengthExceedsMax)
2100 }
2101 }
2102}
2103
2104impl<const MAX: u32> From<StringM<MAX>> for Vec<u8> {
2105 #[must_use]
2106 fn from(v: StringM<MAX>) -> Self {
2107 v.0
2108 }
2109}
2110
2111#[cfg(feature = "alloc")]
2112impl<const MAX: u32> From<&StringM<MAX>> for Vec<u8> {
2113 #[must_use]
2114 fn from(v: &StringM<MAX>) -> Self {
2115 v.0.clone()
2116 }
2117}
2118
2119impl<const MAX: u32> AsRef<Vec<u8>> for StringM<MAX> {
2120 #[must_use]
2121 fn as_ref(&self) -> &Vec<u8> {
2122 &self.0
2123 }
2124}
2125
2126#[cfg(feature = "alloc")]
2127impl<const MAX: u32> TryFrom<&Vec<u8>> for StringM<MAX> {
2128 type Error = Error;
2129
2130 fn try_from(v: &Vec<u8>) -> Result<Self, Error> {
2131 v.as_slice().try_into()
2132 }
2133}
2134
2135#[cfg(feature = "alloc")]
2136impl<const MAX: u32> TryFrom<&[u8]> for StringM<MAX> {
2137 type Error = Error;
2138
2139 fn try_from(v: &[u8]) -> Result<Self, Error> {
2140 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2141 if len <= MAX {
2142 Ok(StringM(v.to_vec()))
2143 } else {
2144 Err(Error::LengthExceedsMax)
2145 }
2146 }
2147}
2148
2149impl<const MAX: u32> AsRef<[u8]> for StringM<MAX> {
2150 #[cfg(feature = "alloc")]
2151 #[must_use]
2152 fn as_ref(&self) -> &[u8] {
2153 self.0.as_ref()
2154 }
2155 #[cfg(not(feature = "alloc"))]
2156 #[must_use]
2157 fn as_ref(&self) -> &[u8] {
2158 self.0
2159 }
2160}
2161
2162#[cfg(feature = "alloc")]
2163impl<const N: usize, const MAX: u32> TryFrom<[u8; N]> for StringM<MAX> {
2164 type Error = Error;
2165
2166 fn try_from(v: [u8; N]) -> Result<Self, Error> {
2167 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2168 if len <= MAX {
2169 Ok(StringM(v.to_vec()))
2170 } else {
2171 Err(Error::LengthExceedsMax)
2172 }
2173 }
2174}
2175
2176#[cfg(feature = "alloc")]
2177impl<const N: usize, const MAX: u32> TryFrom<StringM<MAX>> for [u8; N] {
2178 type Error = StringM<MAX>;
2179
2180 fn try_from(v: StringM<MAX>) -> core::result::Result<Self, Self::Error> {
2181 let s: [u8; N] = v.0.try_into().map_err(StringM::<MAX>)?;
2182 Ok(s)
2183 }
2184}
2185
2186#[cfg(feature = "alloc")]
2187impl<const N: usize, const MAX: u32> TryFrom<&[u8; N]> for StringM<MAX> {
2188 type Error = Error;
2189
2190 fn try_from(v: &[u8; N]) -> Result<Self, Error> {
2191 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2192 if len <= MAX {
2193 Ok(StringM(v.to_vec()))
2194 } else {
2195 Err(Error::LengthExceedsMax)
2196 }
2197 }
2198}
2199
2200#[cfg(not(feature = "alloc"))]
2201impl<const N: usize, const MAX: u32> TryFrom<&'static [u8; N]> for StringM<MAX> {
2202 type Error = Error;
2203
2204 fn try_from(v: &'static [u8; N]) -> Result<Self, Error> {
2205 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2206 if len <= MAX {
2207 Ok(StringM(v))
2208 } else {
2209 Err(Error::LengthExceedsMax)
2210 }
2211 }
2212}
2213
2214#[cfg(feature = "alloc")]
2215impl<const MAX: u32> TryFrom<&String> for StringM<MAX> {
2216 type Error = Error;
2217
2218 fn try_from(v: &String) -> Result<Self, Error> {
2219 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2220 if len <= MAX {
2221 Ok(StringM(v.as_bytes().to_vec()))
2222 } else {
2223 Err(Error::LengthExceedsMax)
2224 }
2225 }
2226}
2227
2228#[cfg(feature = "alloc")]
2229impl<const MAX: u32> TryFrom<String> for StringM<MAX> {
2230 type Error = Error;
2231
2232 fn try_from(v: String) -> Result<Self, Error> {
2233 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2234 if len <= MAX {
2235 Ok(StringM(v.into()))
2236 } else {
2237 Err(Error::LengthExceedsMax)
2238 }
2239 }
2240}
2241
2242#[cfg(feature = "alloc")]
2243impl<const MAX: u32> TryFrom<StringM<MAX>> for String {
2244 type Error = Error;
2245
2246 fn try_from(v: StringM<MAX>) -> Result<Self, Error> {
2247 Ok(String::from_utf8(v.0)?)
2248 }
2249}
2250
2251#[cfg(feature = "alloc")]
2252impl<const MAX: u32> TryFrom<&StringM<MAX>> for String {
2253 type Error = Error;
2254
2255 fn try_from(v: &StringM<MAX>) -> Result<Self, Error> {
2256 Ok(core::str::from_utf8(v.as_ref())?.to_owned())
2257 }
2258}
2259
2260#[cfg(feature = "alloc")]
2261impl<const MAX: u32> TryFrom<&str> for StringM<MAX> {
2262 type Error = Error;
2263
2264 fn try_from(v: &str) -> Result<Self, Error> {
2265 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2266 if len <= MAX {
2267 Ok(StringM(v.into()))
2268 } else {
2269 Err(Error::LengthExceedsMax)
2270 }
2271 }
2272}
2273
2274#[cfg(not(feature = "alloc"))]
2275impl<const MAX: u32> TryFrom<&'static str> for StringM<MAX> {
2276 type Error = Error;
2277
2278 fn try_from(v: &'static str) -> Result<Self, Error> {
2279 let len: u32 = v.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2280 if len <= MAX {
2281 Ok(StringM(v.as_bytes()))
2282 } else {
2283 Err(Error::LengthExceedsMax)
2284 }
2285 }
2286}
2287
2288impl<'a, const MAX: u32> TryFrom<&'a StringM<MAX>> for &'a str {
2289 type Error = Error;
2290
2291 fn try_from(v: &'a StringM<MAX>) -> Result<Self, Error> {
2292 Ok(core::str::from_utf8(v.as_ref())?)
2293 }
2294}
2295
2296impl<const MAX: u32> ReadXdr for StringM<MAX> {
2297 #[cfg(feature = "std")]
2298 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
2299 r.with_limited_depth(|r| {
2300 let len: u32 = u32::read_xdr(r)?;
2301 if len > MAX {
2302 return Err(Error::LengthExceedsMax);
2303 }
2304
2305 r.consume_len(len as usize)?;
2306 let padding = pad_len(len as usize);
2307 r.consume_len(padding)?;
2308
2309 let mut vec = vec![0u8; len as usize];
2310 r.read_exact(&mut vec)?;
2311
2312 let pad = &mut [0u8; 3][..padding];
2313 r.read_exact(pad)?;
2314 if pad.iter().any(|b| *b != 0) {
2315 return Err(Error::NonZeroPadding);
2316 }
2317
2318 Ok(StringM(vec))
2319 })
2320 }
2321}
2322
2323impl<const MAX: u32> WriteXdr for StringM<MAX> {
2324 #[cfg(feature = "std")]
2325 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
2326 w.with_limited_depth(|w| {
2327 let len: u32 = self.len().try_into().map_err(|_| Error::LengthExceedsMax)?;
2328 len.write_xdr(w)?;
2329
2330 w.consume_len(self.len())?;
2331 let padding = pad_len(self.len());
2332 w.consume_len(padding)?;
2333
2334 w.write_all(&self.0)?;
2335
2336 w.write_all(&[0u8; 3][..padding])?;
2337
2338 Ok(())
2339 })
2340 }
2341}
2342
2343#[derive(Default, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
2358#[cfg_attr(
2359 all(feature = "serde", feature = "alloc"),
2360 derive(serde::Serialize, serde::Deserialize),
2361 serde(rename_all = "snake_case")
2362)]
2363pub struct Frame<T>(pub T)
2364where
2365 T: ReadXdr;
2366
2367#[cfg(feature = "schemars")]
2368impl<T: schemars::JsonSchema + ReadXdr> schemars::JsonSchema for Frame<T> {
2369 fn schema_name() -> String {
2370 format!("Frame<{}>", T::schema_name())
2371 }
2372
2373 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
2374 T::json_schema(gen)
2375 }
2376}
2377
2378impl<T> ReadXdr for Frame<T>
2379where
2380 T: ReadXdr,
2381{
2382 #[cfg(feature = "std")]
2383 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
2384 let header = u32::read_xdr(r)?;
2392 let last_record = header >> 31 == 1;
2394 if last_record {
2395 Ok(Self(T::read_xdr(r)?))
2397 } else {
2398 Err(Error::Unsupported)
2401 }
2402 }
2403}
2404
2405#[cfg(feature = "std")]
2408pub struct SkipWhitespace<R: Read> {
2409 pub inner: R,
2410}
2411
2412#[cfg(feature = "std")]
2413impl<R: Read> SkipWhitespace<R> {
2414 pub fn new(inner: R) -> Self {
2415 SkipWhitespace { inner }
2416 }
2417}
2418
2419#[cfg(feature = "std")]
2420impl<R: Read> Read for SkipWhitespace<R> {
2421 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
2422 let n = self.inner.read(buf)?;
2423
2424 let mut written = 0;
2425 for read in 0..n {
2426 if !buf[read].is_ascii_whitespace() {
2427 buf[written] = buf[read];
2428 written += 1;
2429 }
2430 }
2431
2432 Ok(written)
2433 }
2434}
2435
2436#[cfg(all(test, feature = "std"))]
2437mod test_skip_whitespace {
2438 use super::*;
2439
2440 #[test]
2441 fn test() {
2442 struct Test {
2443 input: &'static [u8],
2444 output: &'static [u8],
2445 }
2446 let tests = [
2447 Test {
2448 input: b"",
2449 output: b"",
2450 },
2451 Test {
2452 input: b" \n\t\r",
2453 output: b"",
2454 },
2455 Test {
2456 input: b"a c",
2457 output: b"ac",
2458 },
2459 Test {
2460 input: b"ab cd",
2461 output: b"abcd",
2462 },
2463 Test {
2464 input: b" ab \n cd ",
2465 output: b"abcd",
2466 },
2467 ];
2468 for (i, t) in tests.iter().enumerate() {
2469 let mut skip = SkipWhitespace::new(t.input);
2470 let mut output = Vec::new();
2471 skip.read_to_end(&mut output).unwrap();
2472 assert_eq!(output, t.output, "#{i}");
2473 }
2474 }
2475}
2476
2477#[cfg(feature = "serde")]
2490struct NumberOrString;
2491
2492#[cfg(feature = "serde")]
2493impl<'de> serde_with::DeserializeAs<'de, i64> for NumberOrString {
2494 fn deserialize_as<D>(deserializer: D) -> Result<i64, D::Error>
2495 where
2496 D: serde::Deserializer<'de>,
2497 {
2498 use serde::Deserialize;
2499 #[derive(Deserialize)]
2500 #[serde(untagged)]
2501 enum I64OrString<'a> {
2502 Str(&'a str),
2503 String(String),
2504 I64(i64),
2505 }
2506 match I64OrString::deserialize(deserializer)? {
2507 I64OrString::Str(s) => s.parse().map_err(serde::de::Error::custom),
2508 I64OrString::String(s) => s.parse().map_err(serde::de::Error::custom),
2509 I64OrString::I64(v) => Ok(v),
2510 }
2511 }
2512}
2513
2514#[cfg(feature = "serde")]
2515impl<'de> serde_with::DeserializeAs<'de, u64> for NumberOrString {
2516 fn deserialize_as<D>(deserializer: D) -> Result<u64, D::Error>
2517 where
2518 D: serde::Deserializer<'de>,
2519 {
2520 use serde::Deserialize;
2521 #[derive(Deserialize)]
2522 #[serde(untagged)]
2523 enum U64OrString<'a> {
2524 Str(&'a str),
2525 String(String),
2526 U64(u64),
2527 }
2528 match U64OrString::deserialize(deserializer)? {
2529 U64OrString::Str(s) => s.parse().map_err(serde::de::Error::custom),
2530 U64OrString::String(s) => s.parse().map_err(serde::de::Error::custom),
2531 U64OrString::U64(v) => Ok(v),
2532 }
2533 }
2534}
2535
2536#[cfg(feature = "serde")]
2537impl serde_with::SerializeAs<i64> for NumberOrString {
2538 fn serialize_as<S>(source: &i64, serializer: S) -> Result<S::Ok, S::Error>
2539 where
2540 S: serde::Serializer,
2541 {
2542 serializer.collect_str(source)
2543 }
2544}
2545
2546#[cfg(feature = "serde")]
2547impl serde_with::SerializeAs<u64> for NumberOrString {
2548 fn serialize_as<S>(source: &u64, serializer: S) -> Result<S::Ok, S::Error>
2549 where
2550 S: serde::Serializer,
2551 {
2552 serializer.collect_str(source)
2553 }
2554}
2555
2556#[cfg(feature = "schemars")]
2557impl<T> serde_with::schemars_0_8::JsonSchemaAs<T> for NumberOrString {
2558 fn schema_name() -> String {
2559 <String as schemars::JsonSchema>::schema_name()
2560 }
2561
2562 fn schema_id() -> std::borrow::Cow<'static, str> {
2563 <String as schemars::JsonSchema>::schema_id()
2564 }
2565
2566 fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
2567 <String as schemars::JsonSchema>::json_schema(gen)
2568 }
2569
2570 fn is_referenceable() -> bool {
2571 <String as schemars::JsonSchema>::is_referenceable()
2572 }
2573}
2574
2575#[cfg(all(test, feature = "std"))]
2578mod tests {
2579 use std::io::Cursor;
2580
2581 use super::*;
2582
2583 #[test]
2584 pub fn vec_u8_read_without_padding() {
2585 let buf = Cursor::new(vec![0, 0, 0, 4, 2, 2, 2, 2]);
2586 let v = VecM::<u8, 8>::read_xdr(&mut Limited::new(buf, Limits::none())).unwrap();
2587 assert_eq!(v.to_vec(), vec![2, 2, 2, 2]);
2588 }
2589
2590 #[test]
2591 pub fn vec_u8_read_with_padding() {
2592 let buf = Cursor::new(vec![0, 0, 0, 1, 2, 0, 0, 0]);
2593 let v = VecM::<u8, 8>::read_xdr(&mut Limited::new(buf, Limits::none())).unwrap();
2594 assert_eq!(v.to_vec(), vec![2]);
2595 }
2596
2597 #[test]
2598 pub fn vec_u8_read_with_insufficient_padding() {
2599 let buf = Cursor::new(vec![0, 0, 0, 1, 2, 0, 0]);
2600 let res = VecM::<u8, 8>::read_xdr(&mut Limited::new(buf, Limits::none()));
2601 match res {
2602 Err(Error::Io(_)) => (),
2603 _ => panic!("expected IO error got {res:?}"),
2604 }
2605 }
2606
2607 #[test]
2608 pub fn vec_u8_read_with_non_zero_padding() {
2609 let buf = Cursor::new(vec![0, 0, 0, 1, 2, 3, 0, 0]);
2610 let res = VecM::<u8, 8>::read_xdr(&mut Limited::new(buf, Limits::none()));
2611 match res {
2612 Err(Error::NonZeroPadding) => (),
2613 _ => panic!("expected NonZeroPadding got {res:?}"),
2614 }
2615 }
2616
2617 #[test]
2618 pub fn vec_u8_write_without_padding() {
2619 let mut buf = vec![];
2620 let v: VecM<u8, 8> = vec![2, 2, 2, 2].try_into().unwrap();
2621
2622 v.write_xdr(&mut Limited::new(Cursor::new(&mut buf), Limits::none()))
2623 .unwrap();
2624 assert_eq!(buf, vec![0, 0, 0, 4, 2, 2, 2, 2]);
2625 }
2626
2627 #[test]
2628 pub fn vec_u8_write_with_padding() {
2629 let mut buf = vec![];
2630 let v: VecM<u8, 8> = vec![2].try_into().unwrap();
2631 v.write_xdr(&mut Limited::new(Cursor::new(&mut buf), Limits::none()))
2632 .unwrap();
2633 assert_eq!(buf, vec![0, 0, 0, 1, 2, 0, 0, 0]);
2634 }
2635
2636 #[test]
2637 pub fn arr_u8_read_without_padding() {
2638 let buf = Cursor::new(vec![2, 2, 2, 2]);
2639 let v = <[u8; 4]>::read_xdr(&mut Limited::new(buf, Limits::none())).unwrap();
2640 assert_eq!(v, [2, 2, 2, 2]);
2641 }
2642
2643 #[test]
2644 pub fn arr_u8_read_with_padding() {
2645 let buf = Cursor::new(vec![2, 0, 0, 0]);
2646 let v = <[u8; 1]>::read_xdr(&mut Limited::new(buf, Limits::none())).unwrap();
2647 assert_eq!(v, [2]);
2648 }
2649
2650 #[test]
2651 pub fn arr_u8_read_with_insufficient_padding() {
2652 let buf = Cursor::new(vec![2, 0, 0]);
2653 let res = <[u8; 1]>::read_xdr(&mut Limited::new(buf, Limits::none()));
2654 match res {
2655 Err(Error::Io(_)) => (),
2656 _ => panic!("expected IO error got {res:?}"),
2657 }
2658 }
2659
2660 #[test]
2661 pub fn arr_u8_read_with_non_zero_padding() {
2662 let buf = Cursor::new(vec![2, 3, 0, 0]);
2663 let res = <[u8; 1]>::read_xdr(&mut Limited::new(buf, Limits::none()));
2664 match res {
2665 Err(Error::NonZeroPadding) => (),
2666 _ => panic!("expected NonZeroPadding got {res:?}"),
2667 }
2668 }
2669
2670 #[test]
2671 pub fn arr_u8_write_without_padding() {
2672 let mut buf = vec![];
2673 [2u8, 2, 2, 2]
2674 .write_xdr(&mut Limited::new(Cursor::new(&mut buf), Limits::none()))
2675 .unwrap();
2676 assert_eq!(buf, vec![2, 2, 2, 2]);
2677 }
2678
2679 #[test]
2680 pub fn arr_u8_write_with_padding() {
2681 let mut buf = vec![];
2682 [2u8]
2683 .write_xdr(&mut Limited::new(Cursor::new(&mut buf), Limits::none()))
2684 .unwrap();
2685 assert_eq!(buf, vec![2, 0, 0, 0]);
2686 }
2687}
2688
2689#[cfg(all(test, feature = "std"))]
2690mod test {
2691 use super::*;
2692
2693 #[test]
2694 fn into_option_none() {
2695 let v: VecM<u32, 1> = vec![].try_into().unwrap();
2696 assert_eq!(v.into_option(), None);
2697 }
2698
2699 #[test]
2700 fn into_option_some() {
2701 let v: VecM<_, 1> = vec![1].try_into().unwrap();
2702 assert_eq!(v.into_option(), Some(1));
2703 }
2704
2705 #[test]
2706 fn to_option_none() {
2707 let v: VecM<u32, 1> = vec![].try_into().unwrap();
2708 assert_eq!(v.to_option(), None);
2709 }
2710
2711 #[test]
2712 fn to_option_some() {
2713 let v: VecM<_, 1> = vec![1].try_into().unwrap();
2714 assert_eq!(v.to_option(), Some(1));
2715 }
2716
2717 #[test]
2718 fn depth_limited_read_write_under_the_limit_success() {
2719 let a: Option<Option<Option<u32>>> = Some(Some(Some(5)));
2720 let mut buf = Limited::new(Vec::new(), Limits::depth(4));
2721 a.write_xdr(&mut buf).unwrap();
2722
2723 let mut dlr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::depth(4));
2724 let a_back: Option<Option<Option<u32>>> = ReadXdr::read_xdr(&mut dlr).unwrap();
2725 assert_eq!(a, a_back);
2726 }
2727
2728 #[test]
2729 fn write_over_depth_limit_fail() {
2730 let a: Option<Option<Option<u32>>> = Some(Some(Some(5)));
2731 let mut buf = Limited::new(Vec::new(), Limits::depth(3));
2732 let res = a.write_xdr(&mut buf);
2733 match res {
2734 Err(Error::DepthLimitExceeded) => (),
2735 _ => panic!("expected DepthLimitExceeded got {res:?}"),
2736 }
2737 }
2738
2739 #[test]
2740 fn read_over_depth_limit_fail() {
2741 let read_limits = Limits::depth(3);
2742 let write_limits = Limits::depth(5);
2743 let a: Option<Option<Option<u32>>> = Some(Some(Some(5)));
2744 let mut buf = Limited::new(Vec::new(), write_limits);
2745 a.write_xdr(&mut buf).unwrap();
2746
2747 let mut dlr = Limited::new(Cursor::new(buf.inner.as_slice()), read_limits);
2748 let res: Result<Option<Option<Option<u32>>>, _> = ReadXdr::read_xdr(&mut dlr);
2749 match res {
2750 Err(Error::DepthLimitExceeded) => (),
2751 _ => panic!("expected DepthLimitExceeded got {res:?}"),
2752 }
2753 }
2754
2755 #[test]
2756 fn length_limited_read_write_i32() {
2757 let v = 123i32;
2759 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2760 v.write_xdr(&mut buf).unwrap();
2761 assert_eq!(buf.limits.len, 0);
2762 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(4));
2763 let v_back: i32 = ReadXdr::read_xdr(&mut lr).unwrap();
2764 assert_eq!(buf.limits.len, 0);
2765 assert_eq!(v, v_back);
2766
2767 let v = 123i32;
2769 let mut buf = Limited::new(Vec::new(), Limits::len(5));
2770 v.write_xdr(&mut buf).unwrap();
2771 assert_eq!(buf.limits.len, 1);
2772 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(5));
2773 let v_back: i32 = ReadXdr::read_xdr(&mut lr).unwrap();
2774 assert_eq!(buf.limits.len, 1);
2775 assert_eq!(v, v_back);
2776
2777 let v = 123i32;
2779 let mut buf = Limited::new(Vec::new(), Limits::len(3));
2780 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2781
2782 let v = 123i32;
2784 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2785 v.write_xdr(&mut buf).unwrap();
2786 assert_eq!(buf.limits.len, 0);
2787 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(3));
2788 assert_eq!(
2789 <i32 as ReadXdr>::read_xdr(&mut lr),
2790 Err(Error::LengthLimitExceeded)
2791 );
2792 }
2793
2794 #[test]
2795 fn length_limited_read_write_u32() {
2796 let v = 123u32;
2798 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2799 v.write_xdr(&mut buf).unwrap();
2800 assert_eq!(buf.limits.len, 0);
2801 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(4));
2802 let v_back: u32 = ReadXdr::read_xdr(&mut lr).unwrap();
2803 assert_eq!(buf.limits.len, 0);
2804 assert_eq!(v, v_back);
2805
2806 let v = 123u32;
2808 let mut buf = Limited::new(Vec::new(), Limits::len(5));
2809 v.write_xdr(&mut buf).unwrap();
2810 assert_eq!(buf.limits.len, 1);
2811 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(5));
2812 let v_back: u32 = ReadXdr::read_xdr(&mut lr).unwrap();
2813 assert_eq!(buf.limits.len, 1);
2814 assert_eq!(v, v_back);
2815
2816 let v = 123u32;
2818 let mut buf = Limited::new(Vec::new(), Limits::len(3));
2819 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2820
2821 let v = 123u32;
2823 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2824 v.write_xdr(&mut buf).unwrap();
2825 assert_eq!(buf.limits.len, 0);
2826 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(3));
2827 assert_eq!(
2828 <u32 as ReadXdr>::read_xdr(&mut lr),
2829 Err(Error::LengthLimitExceeded)
2830 );
2831 }
2832
2833 #[test]
2834 fn length_limited_read_write_i64() {
2835 let v = 123i64;
2837 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2838 v.write_xdr(&mut buf).unwrap();
2839 assert_eq!(buf.limits.len, 0);
2840 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(8));
2841 let v_back: i64 = ReadXdr::read_xdr(&mut lr).unwrap();
2842 assert_eq!(buf.limits.len, 0);
2843 assert_eq!(v, v_back);
2844
2845 let v = 123i64;
2847 let mut buf = Limited::new(Vec::new(), Limits::len(9));
2848 v.write_xdr(&mut buf).unwrap();
2849 assert_eq!(buf.limits.len, 1);
2850 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(9));
2851 let v_back: i64 = ReadXdr::read_xdr(&mut lr).unwrap();
2852 assert_eq!(buf.limits.len, 1);
2853 assert_eq!(v, v_back);
2854
2855 let v = 123i64;
2857 let mut buf = Limited::new(Vec::new(), Limits::len(7));
2858 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2859
2860 let v = 123i64;
2862 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2863 v.write_xdr(&mut buf).unwrap();
2864 assert_eq!(buf.limits.len, 0);
2865 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(7));
2866 assert_eq!(
2867 <i64 as ReadXdr>::read_xdr(&mut lr),
2868 Err(Error::LengthLimitExceeded)
2869 );
2870 }
2871
2872 #[test]
2873 fn length_limited_read_write_u64() {
2874 let v = 123u64;
2876 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2877 v.write_xdr(&mut buf).unwrap();
2878 assert_eq!(buf.limits.len, 0);
2879 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(8));
2880 let v_back: u64 = ReadXdr::read_xdr(&mut lr).unwrap();
2881 assert_eq!(buf.limits.len, 0);
2882 assert_eq!(v, v_back);
2883
2884 let v = 123u64;
2886 let mut buf = Limited::new(Vec::new(), Limits::len(9));
2887 v.write_xdr(&mut buf).unwrap();
2888 assert_eq!(buf.limits.len, 1);
2889 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(9));
2890 let v_back: u64 = ReadXdr::read_xdr(&mut lr).unwrap();
2891 assert_eq!(buf.limits.len, 1);
2892 assert_eq!(v, v_back);
2893
2894 let v = 123u64;
2896 let mut buf = Limited::new(Vec::new(), Limits::len(7));
2897 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2898
2899 let v = 123u64;
2901 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2902 v.write_xdr(&mut buf).unwrap();
2903 assert_eq!(buf.limits.len, 0);
2904 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(7));
2905 assert_eq!(
2906 <u64 as ReadXdr>::read_xdr(&mut lr),
2907 Err(Error::LengthLimitExceeded)
2908 );
2909 }
2910
2911 #[test]
2912 fn length_limited_read_write_bool() {
2913 let v = true;
2915 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2916 v.write_xdr(&mut buf).unwrap();
2917 assert_eq!(buf.limits.len, 0);
2918 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(4));
2919 let v_back: bool = ReadXdr::read_xdr(&mut lr).unwrap();
2920 assert_eq!(buf.limits.len, 0);
2921 assert_eq!(v, v_back);
2922
2923 let v = true;
2925 let mut buf = Limited::new(Vec::new(), Limits::len(5));
2926 v.write_xdr(&mut buf).unwrap();
2927 assert_eq!(buf.limits.len, 1);
2928 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(5));
2929 let v_back: bool = ReadXdr::read_xdr(&mut lr).unwrap();
2930 assert_eq!(buf.limits.len, 1);
2931 assert_eq!(v, v_back);
2932
2933 let v = true;
2935 let mut buf = Limited::new(Vec::new(), Limits::len(3));
2936 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2937
2938 let v = true;
2940 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2941 v.write_xdr(&mut buf).unwrap();
2942 assert_eq!(buf.limits.len, 0);
2943 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(3));
2944 assert_eq!(
2945 <bool as ReadXdr>::read_xdr(&mut lr),
2946 Err(Error::LengthLimitExceeded)
2947 );
2948 }
2949
2950 #[test]
2951 fn length_limited_read_write_option() {
2952 let v = Some(true);
2954 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2955 v.write_xdr(&mut buf).unwrap();
2956 assert_eq!(buf.limits.len, 0);
2957 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(8));
2958 let v_back: Option<bool> = ReadXdr::read_xdr(&mut lr).unwrap();
2959 assert_eq!(buf.limits.len, 0);
2960 assert_eq!(v, v_back);
2961
2962 let v = Some(true);
2964 let mut buf = Limited::new(Vec::new(), Limits::len(9));
2965 v.write_xdr(&mut buf).unwrap();
2966 assert_eq!(buf.limits.len, 1);
2967 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(9));
2968 let v_back: Option<bool> = ReadXdr::read_xdr(&mut lr).unwrap();
2969 assert_eq!(buf.limits.len, 1);
2970 assert_eq!(v, v_back);
2971
2972 let v = Some(true);
2974 let mut buf = Limited::new(Vec::new(), Limits::len(7));
2975 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
2976
2977 let v = Some(true);
2979 let mut buf = Limited::new(Vec::new(), Limits::len(8));
2980 v.write_xdr(&mut buf).unwrap();
2981 assert_eq!(buf.limits.len, 0);
2982 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(7));
2983 assert_eq!(
2984 <Option<bool> as ReadXdr>::read_xdr(&mut lr),
2985 Err(Error::LengthLimitExceeded)
2986 );
2987 }
2988
2989 #[test]
2990 fn length_limited_read_write_array_u8() {
2991 let v = [1u8, 2, 3];
2993 let mut buf = Limited::new(Vec::new(), Limits::len(4));
2994 v.write_xdr(&mut buf).unwrap();
2995 assert_eq!(buf.limits.len, 0);
2996 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(4));
2997 let v_back: [u8; 3] = ReadXdr::read_xdr(&mut lr).unwrap();
2998 assert_eq!(buf.limits.len, 0);
2999 assert_eq!(v, v_back);
3000
3001 let v = [1u8, 2, 3];
3003 let mut buf = Limited::new(Vec::new(), Limits::len(5));
3004 v.write_xdr(&mut buf).unwrap();
3005 assert_eq!(buf.limits.len, 1);
3006 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(5));
3007 let v_back: [u8; 3] = ReadXdr::read_xdr(&mut lr).unwrap();
3008 assert_eq!(buf.limits.len, 1);
3009 assert_eq!(v, v_back);
3010
3011 let v = [1u8, 2, 3];
3013 let mut buf = Limited::new(Vec::new(), Limits::len(3));
3014 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
3015
3016 let v = [1u8, 2, 3];
3018 let mut buf = Limited::new(Vec::new(), Limits::len(4));
3019 v.write_xdr(&mut buf).unwrap();
3020 assert_eq!(buf.limits.len, 0);
3021 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(3));
3022 assert_eq!(
3023 <[u8; 3] as ReadXdr>::read_xdr(&mut lr),
3024 Err(Error::LengthLimitExceeded)
3025 );
3026 }
3027
3028 #[test]
3029 fn length_limited_read_write_array_type() {
3030 let v = [true, false, true];
3032 let mut buf = Limited::new(Vec::new(), Limits::len(12));
3033 v.write_xdr(&mut buf).unwrap();
3034 assert_eq!(buf.limits.len, 0);
3035 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(12));
3036 let v_back: [bool; 3] = ReadXdr::read_xdr(&mut lr).unwrap();
3037 assert_eq!(buf.limits.len, 0);
3038 assert_eq!(v, v_back);
3039
3040 let v = [true, false, true];
3042 let mut buf = Limited::new(Vec::new(), Limits::len(13));
3043 v.write_xdr(&mut buf).unwrap();
3044 assert_eq!(buf.limits.len, 1);
3045 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(13));
3046 let v_back: [bool; 3] = ReadXdr::read_xdr(&mut lr).unwrap();
3047 assert_eq!(buf.limits.len, 1);
3048 assert_eq!(v, v_back);
3049
3050 let v = [true, false, true];
3052 let mut buf = Limited::new(Vec::new(), Limits::len(11));
3053 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
3054
3055 let v = [true, false, true];
3057 let mut buf = Limited::new(Vec::new(), Limits::len(12));
3058 v.write_xdr(&mut buf).unwrap();
3059 assert_eq!(buf.limits.len, 0);
3060 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(11));
3061 assert_eq!(
3062 <[bool; 3] as ReadXdr>::read_xdr(&mut lr),
3063 Err(Error::LengthLimitExceeded)
3064 );
3065 }
3066
3067 #[test]
3068 fn length_limited_read_write_vec() {
3069 let v = VecM::<i32, 3>::try_from([1i32, 2, 3]).unwrap();
3071 let mut buf = Limited::new(Vec::new(), Limits::len(16));
3072 v.write_xdr(&mut buf).unwrap();
3073 assert_eq!(buf.limits.len, 0);
3074 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(16));
3075 let v_back: VecM<i32, 3> = ReadXdr::read_xdr(&mut lr).unwrap();
3076 assert_eq!(buf.limits.len, 0);
3077 assert_eq!(v, v_back);
3078
3079 let v = VecM::<i32, 3>::try_from([1i32, 2, 3]).unwrap();
3081 let mut buf = Limited::new(Vec::new(), Limits::len(17));
3082 v.write_xdr(&mut buf).unwrap();
3083 assert_eq!(buf.limits.len, 1);
3084 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(17));
3085 let v_back: VecM<i32, 3> = ReadXdr::read_xdr(&mut lr).unwrap();
3086 assert_eq!(buf.limits.len, 1);
3087 assert_eq!(v, v_back);
3088
3089 let v = VecM::<i32, 3>::try_from([1i32, 2, 3]).unwrap();
3091 let mut buf = Limited::new(Vec::new(), Limits::len(15));
3092 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
3093
3094 let v = VecM::<i32, 3>::try_from([1i32, 2, 3]).unwrap();
3096 let mut buf = Limited::new(Vec::new(), Limits::len(16));
3097 v.write_xdr(&mut buf).unwrap();
3098 assert_eq!(buf.limits.len, 0);
3099 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(15));
3100 assert_eq!(
3101 <VecM<i32, 3> as ReadXdr>::read_xdr(&mut lr),
3102 Err(Error::LengthLimitExceeded)
3103 );
3104 }
3105
3106 #[test]
3107 fn length_limited_read_write_bytes() {
3108 let v = BytesM::<3>::try_from([1u8, 2, 3]).unwrap();
3110 let mut buf = Limited::new(Vec::new(), Limits::len(8));
3111 v.write_xdr(&mut buf).unwrap();
3112 assert_eq!(buf.limits.len, 0);
3113 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(8));
3114 let v_back: BytesM<3> = ReadXdr::read_xdr(&mut lr).unwrap();
3115 assert_eq!(buf.limits.len, 0);
3116 assert_eq!(v, v_back);
3117
3118 let v = BytesM::<3>::try_from([1u8, 2, 3]).unwrap();
3120 let mut buf = Limited::new(Vec::new(), Limits::len(9));
3121 v.write_xdr(&mut buf).unwrap();
3122 assert_eq!(buf.limits.len, 1);
3123 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(9));
3124 let v_back: BytesM<3> = ReadXdr::read_xdr(&mut lr).unwrap();
3125 assert_eq!(buf.limits.len, 1);
3126 assert_eq!(v, v_back);
3127
3128 let v = BytesM::<3>::try_from([1u8, 2, 3]).unwrap();
3130 let mut buf = Limited::new(Vec::new(), Limits::len(7));
3131 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
3132
3133 let v = BytesM::<3>::try_from([1u8, 2, 3]).unwrap();
3135 let mut buf = Limited::new(Vec::new(), Limits::len(8));
3136 v.write_xdr(&mut buf).unwrap();
3137 assert_eq!(buf.limits.len, 0);
3138 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(7));
3139 assert_eq!(
3140 <BytesM<3> as ReadXdr>::read_xdr(&mut lr),
3141 Err(Error::LengthLimitExceeded)
3142 );
3143 }
3144
3145 #[test]
3146 fn length_limited_read_write_string() {
3147 let v = StringM::<3>::try_from("123").unwrap();
3149 let mut buf = Limited::new(Vec::new(), Limits::len(8));
3150 v.write_xdr(&mut buf).unwrap();
3151 assert_eq!(buf.limits.len, 0);
3152 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(8));
3153 let v_back: StringM<3> = ReadXdr::read_xdr(&mut lr).unwrap();
3154 assert_eq!(buf.limits.len, 0);
3155 assert_eq!(v, v_back);
3156
3157 let v = StringM::<3>::try_from("123").unwrap();
3159 let mut buf = Limited::new(Vec::new(), Limits::len(9));
3160 v.write_xdr(&mut buf).unwrap();
3161 assert_eq!(buf.limits.len, 1);
3162 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(9));
3163 let v_back: StringM<3> = ReadXdr::read_xdr(&mut lr).unwrap();
3164 assert_eq!(buf.limits.len, 1);
3165 assert_eq!(v, v_back);
3166
3167 let v = StringM::<3>::try_from("123").unwrap();
3169 let mut buf = Limited::new(Vec::new(), Limits::len(7));
3170 assert_eq!(v.write_xdr(&mut buf), Err(Error::LengthLimitExceeded));
3171
3172 let v = StringM::<3>::try_from("123").unwrap();
3174 let mut buf = Limited::new(Vec::new(), Limits::len(8));
3175 v.write_xdr(&mut buf).unwrap();
3176 assert_eq!(buf.limits.len, 0);
3177 let mut lr = Limited::new(Cursor::new(buf.inner.as_slice()), Limits::len(7));
3178 assert_eq!(
3179 <StringM<3> as ReadXdr>::read_xdr(&mut lr),
3180 Err(Error::LengthLimitExceeded)
3181 );
3182 }
3183}
3184
3185#[cfg(all(test, not(feature = "alloc")))]
3186mod test {
3187 use super::VecM;
3188
3189 #[test]
3190 fn to_option_none() {
3191 let v: VecM<u32, 1> = (&[]).try_into().unwrap();
3192 assert_eq!(v.to_option(), None);
3193 }
3194
3195 #[test]
3196 fn to_option_some() {
3197 let v: VecM<_, 1> = (&[1]).try_into().unwrap();
3198 assert_eq!(v.to_option(), Some(1));
3199 }
3200}
3201
3202#[cfg(all(test, feature = "serde"))]
3203mod tests_for_number_or_string {
3204 use super::*;
3205 use serde::{Deserialize, Serialize};
3206 use serde_with::serde_as;
3207
3208 #[serde_as]
3210 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3211 struct TestI64 {
3212 #[serde_as(as = "NumberOrString")]
3213 val: i64,
3214 }
3215
3216 #[serde_as]
3217 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3218 struct TestU64 {
3219 #[serde_as(as = "NumberOrString")]
3220 val: u64,
3221 }
3222
3223 #[serde_as]
3224 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3225 struct TestOptionI64 {
3226 #[serde_as(as = "Option<NumberOrString>")]
3227 val: Option<i64>,
3228 }
3229
3230 #[serde_as]
3231 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3232 struct TestOptionU64 {
3233 #[serde_as(as = "Option<NumberOrString>")]
3234 val: Option<u64>,
3235 }
3236
3237 #[serde_as]
3238 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3239 struct TestVecI64 {
3240 #[serde_as(as = "Vec<NumberOrString>")]
3241 val: Vec<i64>,
3242 }
3243
3244 #[serde_as]
3245 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3246 struct TestVecU64 {
3247 #[serde_as(as = "Vec<NumberOrString>")]
3248 val: Vec<u64>,
3249 }
3250
3251 #[serde_as]
3253 #[derive(Debug, PartialEq, Deserialize, Serialize)]
3254 #[serde(rename_all = "camelCase")] enum TestEnum {
3256 VariantA {
3257 #[serde(rename = "numVal")]
3258 #[serde_as(as = "NumberOrString")]
3259 num_val: i64,
3260 #[serde(rename = "otherData")]
3261 other_data: String,
3262 },
3263 VariantB {
3264 #[serde_as(as = "NumberOrString")]
3265 count: u64,
3266 },
3267 SimpleVariant,
3268 }
3269
3270 #[test]
3272 fn deserialize_i64_from_json_reader() {
3273 let json = r#"{"val": "123"}"#;
3274 let expected = TestI64 { val: 123 };
3275 assert_eq!(
3276 serde_json::from_reader::<_, TestI64>(Cursor::new(json)).unwrap(),
3277 expected
3278 );
3279 }
3280
3281 #[test]
3282 fn deserialize_i64_from_json_number_positive() {
3283 let json = r#"{"val": 123}"#;
3284 let expected = TestI64 { val: 123 };
3285 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3286 }
3287
3288 #[test]
3289 fn deserialize_i64_from_json_number_negative() {
3290 let json = r#"{"val": -456}"#;
3291 let expected = TestI64 { val: -456 };
3292 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3293 }
3294
3295 #[test]
3296 fn deserialize_i64_from_json_number_zero() {
3297 let json = r#"{"val": 0}"#;
3298 let expected = TestI64 { val: 0 };
3299 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3300 }
3301
3302 #[test]
3303 fn deserialize_i64_from_json_number_max() {
3304 let json = format!(r#"{{"val": {}}}"#, i64::MAX);
3305 let expected = TestI64 { val: i64::MAX };
3306 assert_eq!(serde_json::from_str::<TestI64>(&json).unwrap(), expected);
3307 }
3308
3309 #[test]
3310 fn deserialize_i64_from_json_number_min() {
3311 let json = format!(r#"{{"val": {}}}"#, i64::MIN);
3312 let expected = TestI64 { val: i64::MIN };
3313 assert_eq!(serde_json::from_str::<TestI64>(&json).unwrap(), expected);
3314 }
3315
3316 #[test]
3317 fn deserialize_i64_from_json_string_positive() {
3318 let json = r#"{"val": "789"}"#;
3319 let expected = TestI64 { val: 789 };
3320 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3321 }
3322
3323 #[test]
3324 fn deserialize_i64_from_json_string_negative() {
3325 let json = r#"{"val": "-101"}"#;
3326 let expected = TestI64 { val: -101 };
3327 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3328 }
3329
3330 #[test]
3331 fn deserialize_i64_from_json_string_zero() {
3332 let json = r#"{"val": "0"}"#;
3333 let expected = TestI64 { val: 0 };
3334 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3335 }
3336
3337 #[test]
3338 fn deserialize_i64_from_json_string_max() {
3339 let json = format!(r#"{{"val": "{}"}}"#, i64::MAX);
3340 let expected = TestI64 { val: i64::MAX };
3341 assert_eq!(serde_json::from_str::<TestI64>(&json).unwrap(), expected);
3342 }
3343
3344 #[test]
3345 fn deserialize_i64_from_json_string_min() {
3346 let json = format!(r#"{{"val": "{}"}}"#, i64::MIN);
3347 let expected = TestI64 { val: i64::MIN };
3348 assert_eq!(serde_json::from_str::<TestI64>(&json).unwrap(), expected);
3349 }
3350
3351 #[test]
3352 fn deserialize_i64_from_json_string_with_plus_prefix() {
3353 let json = r#"{"val": "+123"}"#;
3354 let expected = TestI64 { val: 123 };
3355 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3356 }
3357
3358 #[test]
3359 fn deserialize_i64_from_json_string_with_plus_zero() {
3360 let json = r#"{"val": "+0"}"#;
3361 let expected = TestI64 { val: 0 };
3362 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3363 }
3364
3365 #[test]
3366 fn deserialize_i64_from_json_string_with_minus_zero() {
3367 let json = r#"{"val": "-0"}"#;
3368 let expected = TestI64 { val: 0 };
3369 assert_eq!(serde_json::from_str::<TestI64>(json).unwrap(), expected);
3370 }
3371
3372 #[test]
3373 fn deserialize_i64_error_from_json_string_with_leading_whitespace() {
3374 let json = r#"{"val": " 123"}"#;
3375 assert!(serde_json::from_str::<TestI64>(json).is_err());
3376 }
3377
3378 #[test]
3379 fn deserialize_i64_error_from_json_string_with_trailing_whitespace() {
3380 let json = r#"{"val": "123 "}"#;
3381 assert!(serde_json::from_str::<TestI64>(json).is_err());
3382 }
3383
3384 #[test]
3385 fn deserialize_i64_error_from_json_string_with_both_whitespace() {
3386 let json = r#"{"val": " 123 "}"#;
3387 assert!(serde_json::from_str::<TestI64>(json).is_err());
3388 }
3389
3390 #[test]
3391 fn deserialize_i64_error_from_json_string_with_invalid_plus_prefix() {
3392 let json = r#"{"val": "++123"}"#;
3393 assert!(serde_json::from_str::<TestI64>(json).is_err());
3394 }
3395
3396 #[test]
3397 fn deserialize_i64_error_from_json_string_with_invalid_minus_prefix() {
3398 let json = r#"{"val": "--123"}"#;
3399 assert!(serde_json::from_str::<TestI64>(json).is_err());
3400 }
3401
3402 #[test]
3403 fn deserialize_i64_error_from_json_string_with_invalid_mixed_prefix() {
3404 let json = r#"{"val": "+-123"}"#;
3405 assert!(serde_json::from_str::<TestI64>(json).is_err());
3406 }
3407
3408 #[test]
3409 fn deserialize_i64_error_from_string_not_a_number() {
3410 let json = r#"{"val": "abc"}"#;
3411 assert!(serde_json::from_str::<TestI64>(json).is_err());
3412 }
3413
3414 #[test]
3415 fn deserialize_i64_error_from_string_float() {
3416 let json = r#"{"val": "123.45"}"#; assert!(serde_json::from_str::<TestI64>(json).is_err());
3418 }
3419
3420 #[test]
3421 fn deserialize_i64_error_from_string_empty() {
3422 let json = r#"{"val": ""}"#;
3423 assert!(serde_json::from_str::<TestI64>(json).is_err());
3424 }
3425
3426 #[test]
3427 fn deserialize_i64_error_from_string_overflow() {
3428 let overflow_val = i128::from(i64::MAX) + 1;
3429 let json = format!(r#"{{"val": "{overflow_val}"}}"#);
3430 assert!(serde_json::from_str::<TestI64>(&json).is_err());
3431 }
3432
3433 #[test]
3434 fn deserialize_i64_error_from_string_underflow() {
3435 let underflow_val = i128::from(i64::MIN) - 1;
3436 let json = format!(r#"{{"val": "{underflow_val}"}}"#);
3437 assert!(serde_json::from_str::<TestI64>(&json).is_err());
3438 }
3439
3440 #[test]
3441 fn deserialize_i64_error_from_json_float_number() {
3442 let json = r#"{"val": 123.45}"#;
3443 assert!(serde_json::from_str::<TestI64>(json).is_err());
3444 }
3445
3446 #[test]
3447 fn deserialize_i64_error_from_json_bool_true() {
3448 let json = r#"{"val": true}"#;
3449 assert!(serde_json::from_str::<TestI64>(json).is_err());
3450 }
3451
3452 #[test]
3453 fn deserialize_i64_error_from_json_array() {
3454 let json = r#"{"val": []}"#;
3455 assert!(serde_json::from_str::<TestI64>(json).is_err());
3456 }
3457
3458 #[test]
3459 fn deserialize_i64_error_from_json_object() {
3460 let json = r#"{"val": {}}"#;
3461 assert!(serde_json::from_str::<TestI64>(json).is_err());
3462 }
3463
3464 #[test]
3465 fn deserialize_i64_error_from_json_null() {
3466 let json = r#"{"val": null}"#;
3467 assert!(serde_json::from_str::<TestI64>(json).is_err());
3468 }
3469
3470 #[test]
3472 fn deserialize_i64_error_from_hex_string() {
3473 let json = r#"{"val": "0x1A"}"#; assert!(
3476 serde_json::from_str::<TestI64>(json).is_err(),
3477 "Hex string should fail parsing to i64"
3478 );
3479 }
3480
3481 #[test]
3482 fn deserialize_i64_error_from_octal_string() {
3483 let json = r#"{"val": "0o77"}"#; assert!(
3486 serde_json::from_str::<TestI64>(json).is_err(),
3487 "Octal string should fail parsing to i64"
3488 );
3489 }
3490
3491 #[test]
3492 fn deserialize_i64_error_from_scientific_notation_string() {
3493 let json = r#"{"val": "1e3"}"#; assert!(
3496 serde_json::from_str::<TestI64>(json).is_err(),
3497 "Scientific notation string should fail parsing to i64"
3498 );
3499 }
3500
3501 #[test]
3502 fn deserialize_i64_error_from_invalid_scientific_notation_string() {
3503 let json = r#"{"val": "1e"}"#;
3504 assert!(
3505 serde_json::from_str::<TestI64>(json).is_err(),
3506 "Invalid scientific notation string should fail"
3507 );
3508 }
3509
3510 #[test]
3511 fn deserialize_i64_error_from_string_with_underscores() {
3512 let json = r#"{"val": "1_000_000"}"#;
3513 assert!(
3515 serde_json::from_str::<TestI64>(json).is_err(),
3516 "String with underscores should fail parsing to i64"
3517 );
3518 }
3519
3520 #[test]
3521 fn deserialize_i64_from_string_with_leading_zeros() {
3522 let json = r#"{"val": "000123"}"#;
3523 let expected = TestI64 { val: 123 };
3524 assert_eq!(
3526 serde_json::from_str::<TestI64>(json).unwrap(),
3527 expected,
3528 "String with leading zeros should parse"
3529 );
3530 }
3531
3532 #[test]
3533 fn deserialize_i64_from_string_with_leading_zeros_negative() {
3534 let json = r#"{"val": "-000123"}"#;
3535 let expected = TestI64 { val: -123 };
3536 assert_eq!(
3537 serde_json::from_str::<TestI64>(json).unwrap(),
3538 expected,
3539 "Negative string with leading zeros should parse"
3540 );
3541 }
3542
3543 #[test]
3544 fn deserialize_i64_error_from_string_with_decimal_zeros() {
3545 let json = r#"{"val": "123.000"}"#;
3546 assert!(
3548 serde_json::from_str::<TestI64>(json).is_err(),
3549 "String with decimal part should fail parsing to i64"
3550 );
3551 }
3552
3553 #[test]
3554 fn deserialize_i64_error_from_string_with_internal_decimal() {
3555 let json = r#"{"val": "12.345"}"#;
3556 assert!(
3557 serde_json::from_str::<TestI64>(json).is_err(),
3558 "String with internal decimal point should fail"
3559 );
3560 }
3561
3562 #[test]
3563 fn deserialize_i64_error_from_localized_string_commas() {
3564 let json = r#"{"val": "1,234"}"#;
3565 assert!(
3567 serde_json::from_str::<TestI64>(json).is_err(),
3568 "Localized string with commas should fail parsing to i64"
3569 );
3570 }
3571
3572 #[test]
3574 fn deserialize_u64_from_json_reader() {
3575 let json = r#"{"val": "123"}"#;
3576 let expected = TestU64 { val: 123 };
3577 assert_eq!(
3578 serde_json::from_reader::<_, TestU64>(Cursor::new(json)).unwrap(),
3579 expected
3580 );
3581 }
3582
3583 #[test]
3584 fn deserialize_u64_from_json_number() {
3585 let json = r#"{"val": 123}"#;
3586 let expected = TestU64 { val: 123 };
3587 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3588 }
3589
3590 #[test]
3591 fn deserialize_u64_from_json_number_zero() {
3592 let json = r#"{"val": 0}"#;
3593 let expected = TestU64 { val: 0 };
3594 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3595 }
3596
3597 #[test]
3598 fn deserialize_u64_from_json_number_max() {
3599 let json = format!(r#"{{"val": {}}}"#, u64::MAX);
3600 let expected = TestU64 { val: u64::MAX };
3601 assert_eq!(serde_json::from_str::<TestU64>(&json).unwrap(), expected);
3602 }
3603
3604 #[test]
3605 fn deserialize_u64_from_json_string() {
3606 let json = r#"{"val": "789"}"#;
3607 let expected = TestU64 { val: 789 };
3608 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3609 }
3610
3611 #[test]
3612 fn deserialize_u64_from_json_string_zero() {
3613 let json = r#"{"val": "0"}"#;
3614 let expected = TestU64 { val: 0 };
3615 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3616 }
3617
3618 #[test]
3619 fn deserialize_u64_from_json_string_max() {
3620 let json = format!(r#"{{"val": "{}"}}"#, u64::MAX);
3621 let expected = TestU64 { val: u64::MAX };
3622 assert_eq!(serde_json::from_str::<TestU64>(&json).unwrap(), expected);
3623 }
3624
3625 #[test]
3626 fn deserialize_u64_from_json_string_with_plus_prefix() {
3627 let json = r#"{"val": "+123"}"#;
3628 let expected = TestU64 { val: 123 };
3629 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3630 }
3631
3632 #[test]
3633 fn deserialize_u64_from_json_string_with_plus_zero() {
3634 let json = r#"{"val": "+0"}"#;
3635 let expected = TestU64 { val: 0 };
3636 assert_eq!(serde_json::from_str::<TestU64>(json).unwrap(), expected);
3637 }
3638
3639 #[test]
3640 fn deserialize_u64_error_from_json_string_with_leading_whitespace() {
3641 let json = r#"{"val": " 123"}"#;
3642 assert!(serde_json::from_str::<TestU64>(json).is_err());
3643 }
3644
3645 #[test]
3646 fn deserialize_u64_error_from_json_string_with_trailing_whitespace() {
3647 let json = r#"{"val": "123 "}"#;
3648 assert!(serde_json::from_str::<TestU64>(json).is_err());
3649 }
3650
3651 #[test]
3652 fn deserialize_u64_error_from_json_string_with_invalid_plus_prefix() {
3653 let json = r#"{"val": "++123"}"#;
3654 assert!(serde_json::from_str::<TestU64>(json).is_err());
3655 }
3656
3657 #[test]
3658 fn deserialize_u64_error_from_string_negative() {
3659 let json = r#"{"val": "-123"}"#; assert!(serde_json::from_str::<TestU64>(json).is_err());
3661 }
3662
3663 #[test]
3664 fn deserialize_u64_error_from_json_number_negative() {
3665 let json = r#"{"val": -1}"#; assert!(serde_json::from_str::<TestU64>(json).is_err());
3667 }
3668
3669 #[test]
3670 fn deserialize_u64_error_from_string_not_a_number() {
3671 let json = r#"{"val": "abc"}"#;
3672 assert!(serde_json::from_str::<TestU64>(json).is_err());
3673 }
3674
3675 #[test]
3676 fn deserialize_u64_error_from_string_float() {
3677 let json = r#"{"val": "123.45"}"#;
3678 assert!(serde_json::from_str::<TestU64>(json).is_err());
3679 }
3680
3681 #[test]
3682 fn deserialize_u64_error_from_string_empty() {
3683 let json = r#"{"val": ""}"#;
3684 assert!(serde_json::from_str::<TestU64>(json).is_err());
3685 }
3686
3687 #[test]
3688 fn deserialize_u64_error_from_string_overflow() {
3689 let overflow_val = u128::from(u64::MAX) + 1;
3690 let json = format!(r#"{{"val": "{overflow_val}"}}"#);
3691 assert!(serde_json::from_str::<TestU64>(&json).is_err());
3692 }
3693
3694 #[test]
3695 fn deserialize_u64_error_from_json_float_number() {
3696 let json = r#"{"val": 123.45}"#;
3697 assert!(serde_json::from_str::<TestU64>(json).is_err());
3698 }
3699
3700 #[test]
3701 fn deserialize_u64_error_from_json_bool_true() {
3702 let json = r#"{"val": true}"#;
3703 assert!(serde_json::from_str::<TestU64>(json).is_err());
3704 }
3705
3706 #[test]
3707 fn deserialize_u64_error_from_json_array() {
3708 let json = r#"{"val": []}"#;
3709 assert!(serde_json::from_str::<TestU64>(json).is_err());
3710 }
3711
3712 #[test]
3713 fn deserialize_u64_error_from_json_object() {
3714 let json = r#"{"val": {}}"#;
3715 assert!(serde_json::from_str::<TestU64>(json).is_err());
3716 }
3717
3718 #[test]
3719 fn deserialize_u64_error_from_json_null() {
3720 let json = r#"{"val": null}"#;
3721 assert!(serde_json::from_str::<TestU64>(json).is_err());
3722 }
3723
3724 #[test]
3726 fn deserialize_u64_error_from_hex_string() {
3727 let json = r#"{"val": "0x1A"}"#; assert!(
3729 serde_json::from_str::<TestU64>(json).is_err(),
3730 "Hex string should fail parsing to u64"
3731 );
3732 }
3733
3734 #[test]
3735 fn deserialize_u64_error_from_octal_string() {
3736 let json = r#"{"val": "0o77"}"#; assert!(
3738 serde_json::from_str::<TestU64>(json).is_err(),
3739 "Octal string should fail parsing to u64"
3740 );
3741 }
3742
3743 #[test]
3744 fn deserialize_u64_error_from_scientific_notation_string() {
3745 let json = r#"{"val": "1e3"}"#;
3746 assert!(
3747 serde_json::from_str::<TestU64>(json).is_err(),
3748 "Scientific notation string should fail parsing to u64"
3749 );
3750 }
3751
3752 #[test]
3753 fn deserialize_u64_error_from_string_with_underscores() {
3754 let json = r#"{"val": "1_000_000"}"#;
3755 assert!(
3756 serde_json::from_str::<TestU64>(json).is_err(),
3757 "String with underscores should fail parsing to u64"
3758 );
3759 }
3760
3761 #[test]
3762 fn deserialize_u64_from_string_with_leading_zeros() {
3763 let json = r#"{"val": "000123"}"#;
3764 let expected = TestU64 { val: 123 };
3765 assert_eq!(
3766 serde_json::from_str::<TestU64>(json).unwrap(),
3767 expected,
3768 "String with leading zeros should parse to u64"
3769 );
3770 }
3771
3772 #[test]
3773 fn deserialize_u64_error_from_string_with_decimal_zeros() {
3774 let json = r#"{"val": "123.000"}"#;
3775 assert!(
3776 serde_json::from_str::<TestU64>(json).is_err(),
3777 "String with decimal part should fail parsing to u64"
3778 );
3779 }
3780
3781 #[test]
3782 fn deserialize_u64_error_from_localized_string_commas() {
3783 let json = r#"{"val": "1,234"}"#;
3784 assert!(
3785 serde_json::from_str::<TestU64>(json).is_err(),
3786 "Localized string with commas should fail parsing to u64"
3787 );
3788 }
3789
3790 #[test]
3792 fn serialize_i64_positive() {
3793 let data = TestI64 { val: 123 };
3794 let expected_json = r#"{"val":"123"}"#;
3795 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3796 }
3797
3798 #[test]
3799 fn serialize_i64_negative() {
3800 let data = TestI64 { val: -456 };
3801 let expected_json = r#"{"val":"-456"}"#;
3802 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3803 }
3804
3805 #[test]
3806 fn serialize_i64_zero() {
3807 let data = TestI64 { val: 0 };
3808 let expected_json = r#"{"val":"0"}"#;
3809 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3810 }
3811
3812 #[test]
3813 fn serialize_i64_max() {
3814 let data = TestI64 { val: i64::MAX };
3815 let expected_json = format!(r#"{{"val":"{}"}}"#, i64::MAX);
3816 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3817 }
3818
3819 #[test]
3820 fn serialize_i64_min() {
3821 let data = TestI64 { val: i64::MIN };
3822 let expected_json = format!(r#"{{"val":"{}"}}"#, i64::MIN);
3823 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3824 }
3825
3826 #[test]
3828 fn serialize_u64_positive() {
3829 let data = TestU64 { val: 789 };
3830 let expected_json = r#"{"val":"789"}"#;
3831 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3832 }
3833
3834 #[test]
3835 fn serialize_u64_zero() {
3836 let data = TestU64 { val: 0 };
3837 let expected_json = r#"{"val":"0"}"#;
3838 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3839 }
3840
3841 #[test]
3842 fn serialize_u64_max() {
3843 let data = TestU64 { val: u64::MAX };
3844 let expected_json = format!(r#"{{"val":"{}"}}"#, u64::MAX);
3845 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3846 }
3847
3848 #[test]
3850 fn deserialize_option_i64_some_from_json_number() {
3851 let json = r#"{"val": 123}"#;
3852 let expected = TestOptionI64 { val: Some(123) };
3853 assert_eq!(
3854 serde_json::from_str::<TestOptionI64>(json).unwrap(),
3855 expected
3856 );
3857 }
3858
3859 #[test]
3860 fn deserialize_option_i64_some_from_json_string() {
3861 let json = r#"{"val": "456"}"#;
3862 let expected = TestOptionI64 { val: Some(456) };
3863 assert_eq!(
3864 serde_json::from_str::<TestOptionI64>(json).unwrap(),
3865 expected
3866 );
3867 }
3868
3869 #[test]
3870 fn deserialize_option_i64_none_from_json_null() {
3871 let json = r#"{"val": null}"#;
3872 let expected = TestOptionI64 { val: None };
3873 assert_eq!(
3874 serde_json::from_str::<TestOptionI64>(json).unwrap(),
3875 expected
3876 );
3877 }
3878
3879 #[test]
3880 fn deserialize_option_i64_error_from_invalid_string() {
3881 let json = r#"{"val": "abc"}"#;
3882 assert!(serde_json::from_str::<TestOptionI64>(json).is_err());
3883 }
3884
3885 #[test]
3886 fn deserialize_option_i64_error_from_invalid_type() {
3887 let json = r#"{"val": true}"#;
3888 assert!(serde_json::from_str::<TestOptionI64>(json).is_err());
3889 }
3890
3891 #[test]
3892 fn serialize_option_i64_some() {
3893 let data = TestOptionI64 { val: Some(123) };
3894 let expected_json = r#"{"val":"123"}"#;
3895 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3896 }
3897
3898 #[test]
3899 fn serialize_option_i64_none() {
3900 let data = TestOptionI64 { val: None };
3901 let expected_json = r#"{"val":null}"#;
3902 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3903 }
3904
3905 #[test]
3907 fn deserialize_option_u64_some_from_json_number() {
3908 let json = r#"{"val": 123}"#;
3909 let expected = TestOptionU64 { val: Some(123) };
3910 assert_eq!(
3911 serde_json::from_str::<TestOptionU64>(json).unwrap(),
3912 expected
3913 );
3914 }
3915
3916 #[test]
3917 fn deserialize_option_u64_some_from_json_string() {
3918 let json = r#"{"val": "456"}"#;
3919 let expected = TestOptionU64 { val: Some(456) };
3920 assert_eq!(
3921 serde_json::from_str::<TestOptionU64>(json).unwrap(),
3922 expected
3923 );
3924 }
3925
3926 #[test]
3927 fn deserialize_option_u64_none_from_json_null() {
3928 let json = r#"{"val": null}"#;
3929 let expected = TestOptionU64 { val: None };
3930 assert_eq!(
3931 serde_json::from_str::<TestOptionU64>(json).unwrap(),
3932 expected
3933 );
3934 }
3935
3936 #[test]
3937 fn deserialize_option_u64_error_from_invalid_string() {
3938 let json = r#"{"val": "abc"}"#;
3939 assert!(serde_json::from_str::<TestOptionU64>(json).is_err());
3940 }
3941
3942 #[test]
3943 fn deserialize_option_u64_error_from_negative_string() {
3944 let json = r#"{"val": "-1"}"#; assert!(serde_json::from_str::<TestOptionU64>(json).is_err());
3946 }
3947
3948 #[test]
3949 fn serialize_option_u64_some() {
3950 let data = TestOptionU64 { val: Some(123) };
3951 let expected_json = r#"{"val":"123"}"#;
3952 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3953 }
3954
3955 #[test]
3956 fn serialize_option_u64_none() {
3957 let data = TestOptionU64 { val: None };
3958 let expected_json = r#"{"val":null}"#;
3959 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3960 }
3961
3962 #[test]
3964 fn deserialize_vec_i64_empty() {
3965 let json = r#"{"val": []}"#;
3966 let expected = TestVecI64 { val: vec![] };
3967 assert_eq!(serde_json::from_str::<TestVecI64>(json).unwrap(), expected);
3968 }
3969
3970 #[test]
3971 fn deserialize_vec_i64_from_numbers_and_strings() {
3972 let json = r#"{"val": [1, "2", -3, "-4"]}"#;
3973 let expected = TestVecI64 {
3974 val: vec![1, 2, -3, -4],
3975 };
3976 assert_eq!(serde_json::from_str::<TestVecI64>(json).unwrap(), expected);
3977 }
3978
3979 #[test]
3980 fn deserialize_vec_i64_error_if_item_is_invalid_string() {
3981 let json = r#"{"val": [1, "abc", 3]}"#;
3982 let err = serde_json::from_str::<TestVecI64>(json).unwrap_err();
3983 assert!(err.to_string().contains("invalid digit found in string")); }
3986
3987 #[test]
3988 fn deserialize_vec_i64_error_if_item_is_invalid_type() {
3989 let json = r#"{"val": [1, true, 3]}"#;
3990 assert!(serde_json::from_str::<TestVecI64>(json).is_err());
3991 }
3992
3993 #[test]
3994 fn serialize_vec_i64_empty() {
3995 let data = TestVecI64 { val: vec![] };
3996 let expected_json = r#"{"val":[]}"#;
3997 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
3998 }
3999
4000 #[test]
4001 fn serialize_vec_i64_with_values() {
4002 let data = TestVecI64 {
4003 val: vec![1, -2, 0],
4004 };
4005 let expected_json = r#"{"val":["1","-2","0"]}"#;
4006 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
4007 }
4008
4009 #[test]
4011 fn deserialize_vec_u64_empty() {
4012 let json = r#"{"val": []}"#;
4013 let expected = TestVecU64 { val: vec![] };
4014 assert_eq!(serde_json::from_str::<TestVecU64>(json).unwrap(), expected);
4015 }
4016
4017 #[test]
4018 fn deserialize_vec_u64_from_numbers_and_strings() {
4019 let json = r#"{"val": [1, "2", 3, "4"]}"#;
4020 let expected = TestVecU64 {
4021 val: vec![1, 2, 3, 4],
4022 };
4023 assert_eq!(serde_json::from_str::<TestVecU64>(json).unwrap(), expected);
4024 }
4025
4026 #[test]
4027 fn deserialize_vec_u64_error_if_item_is_invalid_string() {
4028 let json = r#"{"val": [1, "abc", 3]}"#;
4029 let err = serde_json::from_str::<TestVecU64>(json).unwrap_err();
4030 assert!(err.to_string().contains("invalid digit found in string"));
4031 }
4032
4033 #[test]
4034 fn deserialize_vec_u64_error_if_item_is_negative_string() {
4035 let json = r#"{"val": [1, "-2", 3]}"#;
4036 let err = serde_json::from_str::<TestVecU64>(json).unwrap_err();
4037 assert!(err.to_string().contains("invalid digit found in string")); }
4039
4040 #[test]
4041 fn deserialize_vec_u64_error_if_item_is_negative_number() {
4042 let json = r#"{"val": [1, -2, 3]}"#;
4043 assert!(serde_json::from_str::<TestVecU64>(json).is_err());
4044 }
4045
4046 #[test]
4047 fn serialize_vec_u64_empty() {
4048 let data = TestVecU64 { val: vec![] };
4049 let expected_json = r#"{"val":[]}"#;
4050 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
4051 }
4052
4053 #[test]
4054 fn serialize_vec_u64_with_values() {
4055 let data = TestVecU64 { val: vec![1, 2, 0] };
4056 let expected_json = r#"{"val":["1","2","0"]}"#;
4057 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
4058 }
4059
4060 #[test]
4062 fn deserialize_enum_variant_a_with_number() {
4063 let json = r#"{"variantA": {"numVal": 123, "otherData": "test"}}"#;
4064 let expected = TestEnum::VariantA {
4065 num_val: 123,
4066 other_data: "test".to_string(),
4067 };
4068 assert_eq!(serde_json::from_str::<TestEnum>(json).unwrap(), expected);
4069 }
4070
4071 #[test]
4072 fn deserialize_enum_variant_a_with_string_number() {
4073 let json = r#"{"variantA": {"numVal": "-45", "otherData": "data"}}"#;
4074 let expected = TestEnum::VariantA {
4075 num_val: -45,
4076 other_data: "data".to_string(),
4077 };
4078 assert_eq!(serde_json::from_str::<TestEnum>(json).unwrap(), expected);
4079 }
4080
4081 #[test]
4082 fn deserialize_enum_variant_b_with_number() {
4083 let json = r#"{"variantB": {"count": 7890}}"#;
4084 let expected = TestEnum::VariantB { count: 7890 };
4085 assert_eq!(serde_json::from_str::<TestEnum>(json).unwrap(), expected);
4086 }
4087
4088 #[test]
4089 fn deserialize_enum_variant_b_with_string_number() {
4090 let json = r#"{"variantB": {"count": "1234567890"}}"#;
4091 let expected = TestEnum::VariantB { count: 1234567890 };
4092 assert_eq!(serde_json::from_str::<TestEnum>(json).unwrap(), expected);
4093 }
4094
4095 #[test]
4096 fn deserialize_enum_variant_a_error_invalid_num_string() {
4097 let json = r#"{"variantA": {"numVal": "abc", "otherData": "test"}}"#;
4098 assert!(serde_json::from_str::<TestEnum>(json).is_err());
4099 }
4100
4101 #[test]
4102 fn serialize_enum_variant_a() {
4103 let data = TestEnum::VariantA {
4104 num_val: 123,
4105 other_data: "test".to_string(),
4106 };
4107 let expected_json = r#"{"variantA":{"numVal":"123","otherData":"test"}}"#;
4109 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
4110 }
4111
4112 #[test]
4113 fn serialize_enum_variant_b() {
4114 let data = TestEnum::VariantB { count: 7890 };
4115 let expected_json = r#"{"variantB":{"count":"7890"}}"#;
4116 assert_eq!(serde_json::to_string(&data).unwrap(), expected_json);
4117 }
4118}
4119
4120mod value;
4121#[allow(unused_imports)]
4122pub use value::*;
4123mod scp_ballot;
4124#[allow(unused_imports)]
4125pub use scp_ballot::*;
4126mod scp_statement_type;
4127#[allow(unused_imports)]
4128pub use scp_statement_type::*;
4129mod scp_nomination;
4130#[allow(unused_imports)]
4131pub use scp_nomination::*;
4132mod scp_statement_prepare;
4133#[allow(unused_imports)]
4134pub use scp_statement_prepare::*;
4135mod scp_statement_confirm;
4136#[allow(unused_imports)]
4137pub use scp_statement_confirm::*;
4138mod scp_statement_externalize;
4139#[allow(unused_imports)]
4140pub use scp_statement_externalize::*;
4141mod scp_statement_pledges;
4142#[allow(unused_imports)]
4143pub use scp_statement_pledges::*;
4144mod scp_statement;
4145#[allow(unused_imports)]
4146pub use scp_statement::*;
4147mod scp_envelope;
4148#[allow(unused_imports)]
4149pub use scp_envelope::*;
4150mod scp_quorum_set;
4151#[allow(unused_imports)]
4152pub use scp_quorum_set::*;
4153mod encoded_ledger_key;
4154#[allow(unused_imports)]
4155pub use encoded_ledger_key::*;
4156mod config_setting_contract_execution_lanes_v0;
4157#[allow(unused_imports)]
4158pub use config_setting_contract_execution_lanes_v0::*;
4159mod config_setting_contract_compute_v0;
4160#[allow(unused_imports)]
4161pub use config_setting_contract_compute_v0::*;
4162mod config_setting_contract_parallel_compute_v0;
4163#[allow(unused_imports)]
4164pub use config_setting_contract_parallel_compute_v0::*;
4165mod config_setting_contract_ledger_cost_v0;
4166#[allow(unused_imports)]
4167pub use config_setting_contract_ledger_cost_v0::*;
4168mod config_setting_contract_ledger_cost_ext_v0;
4169#[allow(unused_imports)]
4170pub use config_setting_contract_ledger_cost_ext_v0::*;
4171mod config_setting_contract_historical_data_v0;
4172#[allow(unused_imports)]
4173pub use config_setting_contract_historical_data_v0::*;
4174mod config_setting_contract_events_v0;
4175#[allow(unused_imports)]
4176pub use config_setting_contract_events_v0::*;
4177mod config_setting_contract_bandwidth_v0;
4178#[allow(unused_imports)]
4179pub use config_setting_contract_bandwidth_v0::*;
4180mod contract_cost_type;
4181#[allow(unused_imports)]
4182pub use contract_cost_type::*;
4183mod contract_cost_param_entry;
4184#[allow(unused_imports)]
4185pub use contract_cost_param_entry::*;
4186mod state_archival_settings;
4187#[allow(unused_imports)]
4188pub use state_archival_settings::*;
4189mod eviction_iterator;
4190#[allow(unused_imports)]
4191pub use eviction_iterator::*;
4192mod config_setting_scp_timing;
4193#[allow(unused_imports)]
4194pub use config_setting_scp_timing::*;
4195mod frozen_ledger_keys;
4196#[allow(unused_imports)]
4197pub use frozen_ledger_keys::*;
4198mod frozen_ledger_keys_delta;
4199#[allow(unused_imports)]
4200pub use frozen_ledger_keys_delta::*;
4201mod freeze_bypass_txs;
4202#[allow(unused_imports)]
4203pub use freeze_bypass_txs::*;
4204mod freeze_bypass_txs_delta;
4205#[allow(unused_imports)]
4206pub use freeze_bypass_txs_delta::*;
4207mod contract_cost_count_limit;
4208#[allow(unused_imports)]
4209pub use contract_cost_count_limit::*;
4210mod contract_cost_params;
4211#[allow(unused_imports)]
4212pub use contract_cost_params::*;
4213mod config_setting_id;
4214#[allow(unused_imports)]
4215pub use config_setting_id::*;
4216mod config_setting_entry;
4217#[allow(unused_imports)]
4218pub use config_setting_entry::*;
4219mod sc_env_meta_kind;
4220#[allow(unused_imports)]
4221pub use sc_env_meta_kind::*;
4222mod sc_env_meta_entry_interface_version;
4223#[allow(unused_imports)]
4224pub use sc_env_meta_entry_interface_version::*;
4225mod sc_env_meta_entry;
4226#[allow(unused_imports)]
4227pub use sc_env_meta_entry::*;
4228mod sc_meta_v0;
4229#[allow(unused_imports)]
4230pub use sc_meta_v0::*;
4231mod sc_meta_kind;
4232#[allow(unused_imports)]
4233pub use sc_meta_kind::*;
4234mod sc_meta_entry;
4235#[allow(unused_imports)]
4236pub use sc_meta_entry::*;
4237mod sc_spec_doc_limit;
4238#[allow(unused_imports)]
4239pub use sc_spec_doc_limit::*;
4240mod sc_spec_type;
4241#[allow(unused_imports)]
4242pub use sc_spec_type::*;
4243mod sc_spec_type_option;
4244#[allow(unused_imports)]
4245pub use sc_spec_type_option::*;
4246mod sc_spec_type_result;
4247#[allow(unused_imports)]
4248pub use sc_spec_type_result::*;
4249mod sc_spec_type_vec;
4250#[allow(unused_imports)]
4251pub use sc_spec_type_vec::*;
4252mod sc_spec_type_map;
4253#[allow(unused_imports)]
4254pub use sc_spec_type_map::*;
4255mod sc_spec_type_tuple;
4256#[allow(unused_imports)]
4257pub use sc_spec_type_tuple::*;
4258mod sc_spec_type_bytes_n;
4259#[allow(unused_imports)]
4260pub use sc_spec_type_bytes_n::*;
4261mod sc_spec_type_udt;
4262#[allow(unused_imports)]
4263pub use sc_spec_type_udt::*;
4264mod sc_spec_type_def;
4265#[allow(unused_imports)]
4266pub use sc_spec_type_def::*;
4267mod sc_spec_udt_struct_field_v0;
4268#[allow(unused_imports)]
4269pub use sc_spec_udt_struct_field_v0::*;
4270mod sc_spec_udt_struct_v0;
4271#[allow(unused_imports)]
4272pub use sc_spec_udt_struct_v0::*;
4273mod sc_spec_udt_union_case_void_v0;
4274#[allow(unused_imports)]
4275pub use sc_spec_udt_union_case_void_v0::*;
4276mod sc_spec_udt_union_case_tuple_v0;
4277#[allow(unused_imports)]
4278pub use sc_spec_udt_union_case_tuple_v0::*;
4279mod sc_spec_udt_union_case_v0_kind;
4280#[allow(unused_imports)]
4281pub use sc_spec_udt_union_case_v0_kind::*;
4282mod sc_spec_udt_union_case_v0;
4283#[allow(unused_imports)]
4284pub use sc_spec_udt_union_case_v0::*;
4285mod sc_spec_udt_union_v0;
4286#[allow(unused_imports)]
4287pub use sc_spec_udt_union_v0::*;
4288mod sc_spec_udt_enum_case_v0;
4289#[allow(unused_imports)]
4290pub use sc_spec_udt_enum_case_v0::*;
4291mod sc_spec_udt_enum_v0;
4292#[allow(unused_imports)]
4293pub use sc_spec_udt_enum_v0::*;
4294mod sc_spec_udt_error_enum_case_v0;
4295#[allow(unused_imports)]
4296pub use sc_spec_udt_error_enum_case_v0::*;
4297mod sc_spec_udt_error_enum_v0;
4298#[allow(unused_imports)]
4299pub use sc_spec_udt_error_enum_v0::*;
4300mod sc_spec_function_input_v0;
4301#[allow(unused_imports)]
4302pub use sc_spec_function_input_v0::*;
4303mod sc_spec_function_v0;
4304#[allow(unused_imports)]
4305pub use sc_spec_function_v0::*;
4306mod sc_spec_event_param_location_v0;
4307#[allow(unused_imports)]
4308pub use sc_spec_event_param_location_v0::*;
4309mod sc_spec_event_param_v0;
4310#[allow(unused_imports)]
4311pub use sc_spec_event_param_v0::*;
4312mod sc_spec_event_data_format;
4313#[allow(unused_imports)]
4314pub use sc_spec_event_data_format::*;
4315mod sc_spec_event_v0;
4316#[allow(unused_imports)]
4317pub use sc_spec_event_v0::*;
4318mod sc_spec_entry_kind;
4319#[allow(unused_imports)]
4320pub use sc_spec_entry_kind::*;
4321mod sc_spec_entry;
4322#[allow(unused_imports)]
4323pub use sc_spec_entry::*;
4324mod sc_val_type;
4325#[allow(unused_imports)]
4326pub use sc_val_type::*;
4327mod sc_error_type;
4328#[allow(unused_imports)]
4329pub use sc_error_type::*;
4330mod sc_error_code;
4331#[allow(unused_imports)]
4332pub use sc_error_code::*;
4333mod sc_error;
4334#[allow(unused_imports)]
4335pub use sc_error::*;
4336mod u_int128_parts;
4337#[allow(unused_imports)]
4338pub use u_int128_parts::*;
4339mod int128_parts;
4340#[allow(unused_imports)]
4341pub use int128_parts::*;
4342mod u_int256_parts;
4343#[allow(unused_imports)]
4344pub use u_int256_parts::*;
4345mod int256_parts;
4346#[allow(unused_imports)]
4347pub use int256_parts::*;
4348mod contract_executable_type;
4349#[allow(unused_imports)]
4350pub use contract_executable_type::*;
4351mod contract_executable;
4352#[allow(unused_imports)]
4353pub use contract_executable::*;
4354mod sc_address_type;
4355#[allow(unused_imports)]
4356pub use sc_address_type::*;
4357mod muxed_ed25519_account;
4358#[allow(unused_imports)]
4359pub use muxed_ed25519_account::*;
4360mod sc_address;
4361#[allow(unused_imports)]
4362pub use sc_address::*;
4363mod scsymbol_limit;
4364#[allow(unused_imports)]
4365pub use scsymbol_limit::*;
4366mod sc_vec;
4367#[allow(unused_imports)]
4368pub use sc_vec::*;
4369mod sc_map;
4370#[allow(unused_imports)]
4371pub use sc_map::*;
4372mod sc_bytes;
4373#[allow(unused_imports)]
4374pub use sc_bytes::*;
4375mod sc_string;
4376#[allow(unused_imports)]
4377pub use sc_string::*;
4378mod sc_symbol;
4379#[allow(unused_imports)]
4380pub use sc_symbol::*;
4381mod sc_nonce_key;
4382#[allow(unused_imports)]
4383pub use sc_nonce_key::*;
4384mod sc_contract_instance;
4385#[allow(unused_imports)]
4386pub use sc_contract_instance::*;
4387mod sc_val;
4388#[allow(unused_imports)]
4389pub use sc_val::*;
4390mod sc_map_entry;
4391#[allow(unused_imports)]
4392pub use sc_map_entry::*;
4393mod ledger_close_meta_batch;
4394#[allow(unused_imports)]
4395pub use ledger_close_meta_batch::*;
4396mod stored_transaction_set;
4397#[allow(unused_imports)]
4398pub use stored_transaction_set::*;
4399mod stored_debug_transaction_set;
4400#[allow(unused_imports)]
4401pub use stored_debug_transaction_set::*;
4402mod persisted_scp_state_v0;
4403#[allow(unused_imports)]
4404pub use persisted_scp_state_v0::*;
4405mod persisted_scp_state_v1;
4406#[allow(unused_imports)]
4407pub use persisted_scp_state_v1::*;
4408mod persisted_scp_state;
4409#[allow(unused_imports)]
4410pub use persisted_scp_state::*;
4411mod thresholds;
4412#[allow(unused_imports)]
4413pub use thresholds::*;
4414mod string32;
4415#[allow(unused_imports)]
4416pub use string32::*;
4417mod string64;
4418#[allow(unused_imports)]
4419pub use string64::*;
4420mod sequence_number;
4421#[allow(unused_imports)]
4422pub use sequence_number::*;
4423mod data_value;
4424#[allow(unused_imports)]
4425pub use data_value::*;
4426mod asset_code4;
4427#[allow(unused_imports)]
4428pub use asset_code4::*;
4429mod asset_code12;
4430#[allow(unused_imports)]
4431pub use asset_code12::*;
4432mod asset_type;
4433#[allow(unused_imports)]
4434pub use asset_type::*;
4435mod asset_code;
4436#[allow(unused_imports)]
4437pub use asset_code::*;
4438mod alpha_num4;
4439#[allow(unused_imports)]
4440pub use alpha_num4::*;
4441mod alpha_num12;
4442#[allow(unused_imports)]
4443pub use alpha_num12::*;
4444mod asset;
4445#[allow(unused_imports)]
4446pub use asset::*;
4447mod price;
4448#[allow(unused_imports)]
4449pub use price::*;
4450mod liabilities;
4451#[allow(unused_imports)]
4452pub use liabilities::*;
4453mod threshold_indexes;
4454#[allow(unused_imports)]
4455pub use threshold_indexes::*;
4456mod ledger_entry_type;
4457#[allow(unused_imports)]
4458pub use ledger_entry_type::*;
4459mod signer;
4460#[allow(unused_imports)]
4461pub use signer::*;
4462mod account_flags;
4463#[allow(unused_imports)]
4464pub use account_flags::*;
4465mod mask_account_flags;
4466#[allow(unused_imports)]
4467pub use mask_account_flags::*;
4468mod mask_account_flags_v17;
4469#[allow(unused_imports)]
4470pub use mask_account_flags_v17::*;
4471mod max_signers;
4472#[allow(unused_imports)]
4473pub use max_signers::*;
4474mod sponsorship_descriptor;
4475#[allow(unused_imports)]
4476pub use sponsorship_descriptor::*;
4477mod account_entry_extension_v3;
4478#[allow(unused_imports)]
4479pub use account_entry_extension_v3::*;
4480mod account_entry_extension_v2_ext;
4481#[allow(unused_imports)]
4482pub use account_entry_extension_v2_ext::*;
4483mod account_entry_extension_v2;
4484#[allow(unused_imports)]
4485pub use account_entry_extension_v2::*;
4486mod account_entry_extension_v1_ext;
4487#[allow(unused_imports)]
4488pub use account_entry_extension_v1_ext::*;
4489mod account_entry_extension_v1;
4490#[allow(unused_imports)]
4491pub use account_entry_extension_v1::*;
4492mod account_entry_ext;
4493#[allow(unused_imports)]
4494pub use account_entry_ext::*;
4495mod account_entry;
4496#[allow(unused_imports)]
4497pub use account_entry::*;
4498mod trust_line_flags;
4499#[allow(unused_imports)]
4500pub use trust_line_flags::*;
4501mod mask_trustline_flags;
4502#[allow(unused_imports)]
4503pub use mask_trustline_flags::*;
4504mod mask_trustline_flags_v13;
4505#[allow(unused_imports)]
4506pub use mask_trustline_flags_v13::*;
4507mod mask_trustline_flags_v17;
4508#[allow(unused_imports)]
4509pub use mask_trustline_flags_v17::*;
4510mod liquidity_pool_type;
4511#[allow(unused_imports)]
4512pub use liquidity_pool_type::*;
4513mod trust_line_asset;
4514#[allow(unused_imports)]
4515pub use trust_line_asset::*;
4516mod trust_line_entry_extension_v2_ext;
4517#[allow(unused_imports)]
4518pub use trust_line_entry_extension_v2_ext::*;
4519mod trust_line_entry_extension_v2;
4520#[allow(unused_imports)]
4521pub use trust_line_entry_extension_v2::*;
4522mod trust_line_entry_v1_ext;
4523#[allow(unused_imports)]
4524pub use trust_line_entry_v1_ext::*;
4525mod trust_line_entry_v1;
4526#[allow(unused_imports)]
4527pub use trust_line_entry_v1::*;
4528mod trust_line_entry_ext;
4529#[allow(unused_imports)]
4530pub use trust_line_entry_ext::*;
4531mod trust_line_entry;
4532#[allow(unused_imports)]
4533pub use trust_line_entry::*;
4534mod offer_entry_flags;
4535#[allow(unused_imports)]
4536pub use offer_entry_flags::*;
4537mod mask_offerentry_flags;
4538#[allow(unused_imports)]
4539pub use mask_offerentry_flags::*;
4540mod offer_entry_ext;
4541#[allow(unused_imports)]
4542pub use offer_entry_ext::*;
4543mod offer_entry;
4544#[allow(unused_imports)]
4545pub use offer_entry::*;
4546mod data_entry_ext;
4547#[allow(unused_imports)]
4548pub use data_entry_ext::*;
4549mod data_entry;
4550#[allow(unused_imports)]
4551pub use data_entry::*;
4552mod claim_predicate_type;
4553#[allow(unused_imports)]
4554pub use claim_predicate_type::*;
4555mod claim_predicate;
4556#[allow(unused_imports)]
4557pub use claim_predicate::*;
4558mod claimant_type;
4559#[allow(unused_imports)]
4560pub use claimant_type::*;
4561mod claimant_v0;
4562#[allow(unused_imports)]
4563pub use claimant_v0::*;
4564mod claimant;
4565#[allow(unused_imports)]
4566pub use claimant::*;
4567mod claimable_balance_flags;
4568#[allow(unused_imports)]
4569pub use claimable_balance_flags::*;
4570mod mask_claimable_balance_flags;
4571#[allow(unused_imports)]
4572pub use mask_claimable_balance_flags::*;
4573mod claimable_balance_entry_extension_v1_ext;
4574#[allow(unused_imports)]
4575pub use claimable_balance_entry_extension_v1_ext::*;
4576mod claimable_balance_entry_extension_v1;
4577#[allow(unused_imports)]
4578pub use claimable_balance_entry_extension_v1::*;
4579mod claimable_balance_entry_ext;
4580#[allow(unused_imports)]
4581pub use claimable_balance_entry_ext::*;
4582mod claimable_balance_entry;
4583#[allow(unused_imports)]
4584pub use claimable_balance_entry::*;
4585mod liquidity_pool_constant_product_parameters;
4586#[allow(unused_imports)]
4587pub use liquidity_pool_constant_product_parameters::*;
4588mod liquidity_pool_entry_constant_product;
4589#[allow(unused_imports)]
4590pub use liquidity_pool_entry_constant_product::*;
4591mod liquidity_pool_entry_body;
4592#[allow(unused_imports)]
4593pub use liquidity_pool_entry_body::*;
4594mod liquidity_pool_entry;
4595#[allow(unused_imports)]
4596pub use liquidity_pool_entry::*;
4597mod contract_data_durability;
4598#[allow(unused_imports)]
4599pub use contract_data_durability::*;
4600mod contract_data_entry;
4601#[allow(unused_imports)]
4602pub use contract_data_entry::*;
4603mod contract_code_cost_inputs;
4604#[allow(unused_imports)]
4605pub use contract_code_cost_inputs::*;
4606mod contract_code_entry_v1;
4607#[allow(unused_imports)]
4608pub use contract_code_entry_v1::*;
4609mod contract_code_entry_ext;
4610#[allow(unused_imports)]
4611pub use contract_code_entry_ext::*;
4612mod contract_code_entry;
4613#[allow(unused_imports)]
4614pub use contract_code_entry::*;
4615mod ttl_entry;
4616#[allow(unused_imports)]
4617pub use ttl_entry::*;
4618mod ledger_entry_extension_v1_ext;
4619#[allow(unused_imports)]
4620pub use ledger_entry_extension_v1_ext::*;
4621mod ledger_entry_extension_v1;
4622#[allow(unused_imports)]
4623pub use ledger_entry_extension_v1::*;
4624mod ledger_entry_data;
4625#[allow(unused_imports)]
4626pub use ledger_entry_data::*;
4627mod ledger_entry_ext;
4628#[allow(unused_imports)]
4629pub use ledger_entry_ext::*;
4630mod ledger_entry;
4631#[allow(unused_imports)]
4632pub use ledger_entry::*;
4633mod ledger_key_account;
4634#[allow(unused_imports)]
4635pub use ledger_key_account::*;
4636mod ledger_key_trust_line;
4637#[allow(unused_imports)]
4638pub use ledger_key_trust_line::*;
4639mod ledger_key_offer;
4640#[allow(unused_imports)]
4641pub use ledger_key_offer::*;
4642mod ledger_key_data;
4643#[allow(unused_imports)]
4644pub use ledger_key_data::*;
4645mod ledger_key_claimable_balance;
4646#[allow(unused_imports)]
4647pub use ledger_key_claimable_balance::*;
4648mod ledger_key_liquidity_pool;
4649#[allow(unused_imports)]
4650pub use ledger_key_liquidity_pool::*;
4651mod ledger_key_contract_data;
4652#[allow(unused_imports)]
4653pub use ledger_key_contract_data::*;
4654mod ledger_key_contract_code;
4655#[allow(unused_imports)]
4656pub use ledger_key_contract_code::*;
4657mod ledger_key_config_setting;
4658#[allow(unused_imports)]
4659pub use ledger_key_config_setting::*;
4660mod ledger_key_ttl;
4661#[allow(unused_imports)]
4662pub use ledger_key_ttl::*;
4663mod ledger_key;
4664#[allow(unused_imports)]
4665pub use ledger_key::*;
4666mod envelope_type;
4667#[allow(unused_imports)]
4668pub use envelope_type::*;
4669mod bucket_list_type;
4670#[allow(unused_imports)]
4671pub use bucket_list_type::*;
4672mod bucket_entry_type;
4673#[allow(unused_imports)]
4674pub use bucket_entry_type::*;
4675mod hot_archive_bucket_entry_type;
4676#[allow(unused_imports)]
4677pub use hot_archive_bucket_entry_type::*;
4678mod bucket_metadata_ext;
4679#[allow(unused_imports)]
4680pub use bucket_metadata_ext::*;
4681mod bucket_metadata;
4682#[allow(unused_imports)]
4683pub use bucket_metadata::*;
4684mod bucket_entry;
4685#[allow(unused_imports)]
4686pub use bucket_entry::*;
4687mod hot_archive_bucket_entry;
4688#[allow(unused_imports)]
4689pub use hot_archive_bucket_entry::*;
4690mod upgrade_type;
4691#[allow(unused_imports)]
4692pub use upgrade_type::*;
4693mod stellar_value_type;
4694#[allow(unused_imports)]
4695pub use stellar_value_type::*;
4696mod ledger_close_value_signature;
4697#[allow(unused_imports)]
4698pub use ledger_close_value_signature::*;
4699mod stellar_value_proposed_value;
4700#[allow(unused_imports)]
4701pub use stellar_value_proposed_value::*;
4702mod stellar_value_ext;
4703#[allow(unused_imports)]
4704pub use stellar_value_ext::*;
4705mod stellar_value;
4706#[allow(unused_imports)]
4707pub use stellar_value::*;
4708mod mask_ledger_header_flags;
4709#[allow(unused_imports)]
4710pub use mask_ledger_header_flags::*;
4711mod ledger_header_flags;
4712#[allow(unused_imports)]
4713pub use ledger_header_flags::*;
4714mod ledger_header_extension_v1_ext;
4715#[allow(unused_imports)]
4716pub use ledger_header_extension_v1_ext::*;
4717mod ledger_header_extension_v1;
4718#[allow(unused_imports)]
4719pub use ledger_header_extension_v1::*;
4720mod ledger_header_ext;
4721#[allow(unused_imports)]
4722pub use ledger_header_ext::*;
4723mod ledger_header;
4724#[allow(unused_imports)]
4725pub use ledger_header::*;
4726mod ledger_upgrade_type;
4727#[allow(unused_imports)]
4728pub use ledger_upgrade_type::*;
4729mod config_upgrade_set_key;
4730#[allow(unused_imports)]
4731pub use config_upgrade_set_key::*;
4732mod ledger_upgrade;
4733#[allow(unused_imports)]
4734pub use ledger_upgrade::*;
4735mod config_upgrade_set;
4736#[allow(unused_imports)]
4737pub use config_upgrade_set::*;
4738mod tx_set_component_type;
4739#[allow(unused_imports)]
4740pub use tx_set_component_type::*;
4741mod dependent_tx_cluster;
4742#[allow(unused_imports)]
4743pub use dependent_tx_cluster::*;
4744mod parallel_tx_execution_stage;
4745#[allow(unused_imports)]
4746pub use parallel_tx_execution_stage::*;
4747mod parallel_txs_component;
4748#[allow(unused_imports)]
4749pub use parallel_txs_component::*;
4750mod tx_set_component_txs_maybe_discounted_fee;
4751#[allow(unused_imports)]
4752pub use tx_set_component_txs_maybe_discounted_fee::*;
4753mod tx_set_component;
4754#[allow(unused_imports)]
4755pub use tx_set_component::*;
4756mod transaction_phase;
4757#[allow(unused_imports)]
4758pub use transaction_phase::*;
4759mod transaction_set;
4760#[allow(unused_imports)]
4761pub use transaction_set::*;
4762mod transaction_set_v1;
4763#[allow(unused_imports)]
4764pub use transaction_set_v1::*;
4765mod generalized_transaction_set;
4766#[allow(unused_imports)]
4767pub use generalized_transaction_set::*;
4768mod transaction_result_pair;
4769#[allow(unused_imports)]
4770pub use transaction_result_pair::*;
4771mod transaction_result_set;
4772#[allow(unused_imports)]
4773pub use transaction_result_set::*;
4774mod transaction_history_entry_ext;
4775#[allow(unused_imports)]
4776pub use transaction_history_entry_ext::*;
4777mod transaction_history_entry;
4778#[allow(unused_imports)]
4779pub use transaction_history_entry::*;
4780mod transaction_history_result_entry_ext;
4781#[allow(unused_imports)]
4782pub use transaction_history_result_entry_ext::*;
4783mod transaction_history_result_entry;
4784#[allow(unused_imports)]
4785pub use transaction_history_result_entry::*;
4786mod ledger_header_history_entry_ext;
4787#[allow(unused_imports)]
4788pub use ledger_header_history_entry_ext::*;
4789mod ledger_header_history_entry;
4790#[allow(unused_imports)]
4791pub use ledger_header_history_entry::*;
4792mod ledger_scp_messages;
4793#[allow(unused_imports)]
4794pub use ledger_scp_messages::*;
4795mod scp_history_entry_v0;
4796#[allow(unused_imports)]
4797pub use scp_history_entry_v0::*;
4798mod scp_history_entry;
4799#[allow(unused_imports)]
4800pub use scp_history_entry::*;
4801mod ledger_entry_change_type;
4802#[allow(unused_imports)]
4803pub use ledger_entry_change_type::*;
4804mod ledger_entry_change;
4805#[allow(unused_imports)]
4806pub use ledger_entry_change::*;
4807mod ledger_entry_changes;
4808#[allow(unused_imports)]
4809pub use ledger_entry_changes::*;
4810mod operation_meta;
4811#[allow(unused_imports)]
4812pub use operation_meta::*;
4813mod transaction_meta_v1;
4814#[allow(unused_imports)]
4815pub use transaction_meta_v1::*;
4816mod transaction_meta_v2;
4817#[allow(unused_imports)]
4818pub use transaction_meta_v2::*;
4819mod contract_event_type;
4820#[allow(unused_imports)]
4821pub use contract_event_type::*;
4822mod contract_event_v0;
4823#[allow(unused_imports)]
4824pub use contract_event_v0::*;
4825mod contract_event_body;
4826#[allow(unused_imports)]
4827pub use contract_event_body::*;
4828mod contract_event;
4829#[allow(unused_imports)]
4830pub use contract_event::*;
4831mod diagnostic_event;
4832#[allow(unused_imports)]
4833pub use diagnostic_event::*;
4834mod soroban_transaction_meta_ext_v1;
4835#[allow(unused_imports)]
4836pub use soroban_transaction_meta_ext_v1::*;
4837mod soroban_transaction_meta_ext;
4838#[allow(unused_imports)]
4839pub use soroban_transaction_meta_ext::*;
4840mod soroban_transaction_meta;
4841#[allow(unused_imports)]
4842pub use soroban_transaction_meta::*;
4843mod transaction_meta_v3;
4844#[allow(unused_imports)]
4845pub use transaction_meta_v3::*;
4846mod operation_meta_v2;
4847#[allow(unused_imports)]
4848pub use operation_meta_v2::*;
4849mod soroban_transaction_meta_v2;
4850#[allow(unused_imports)]
4851pub use soroban_transaction_meta_v2::*;
4852mod transaction_event_stage;
4853#[allow(unused_imports)]
4854pub use transaction_event_stage::*;
4855mod transaction_event;
4856#[allow(unused_imports)]
4857pub use transaction_event::*;
4858mod transaction_meta_v4;
4859#[allow(unused_imports)]
4860pub use transaction_meta_v4::*;
4861mod invoke_host_function_success_pre_image;
4862#[allow(unused_imports)]
4863pub use invoke_host_function_success_pre_image::*;
4864mod transaction_meta;
4865#[allow(unused_imports)]
4866pub use transaction_meta::*;
4867mod transaction_result_meta;
4868#[allow(unused_imports)]
4869pub use transaction_result_meta::*;
4870mod transaction_result_meta_v1;
4871#[allow(unused_imports)]
4872pub use transaction_result_meta_v1::*;
4873mod upgrade_entry_meta;
4874#[allow(unused_imports)]
4875pub use upgrade_entry_meta::*;
4876mod ledger_close_meta_v0;
4877#[allow(unused_imports)]
4878pub use ledger_close_meta_v0::*;
4879mod ledger_close_meta_ext_v1;
4880#[allow(unused_imports)]
4881pub use ledger_close_meta_ext_v1::*;
4882mod ledger_close_meta_ext;
4883#[allow(unused_imports)]
4884pub use ledger_close_meta_ext::*;
4885mod ledger_close_meta_v1;
4886#[allow(unused_imports)]
4887pub use ledger_close_meta_v1::*;
4888mod ledger_close_meta_v2;
4889#[allow(unused_imports)]
4890pub use ledger_close_meta_v2::*;
4891mod ledger_close_meta;
4892#[allow(unused_imports)]
4893pub use ledger_close_meta::*;
4894mod error_code;
4895#[allow(unused_imports)]
4896pub use error_code::*;
4897mod s_error;
4898#[allow(unused_imports)]
4899pub use s_error::*;
4900mod send_more;
4901#[allow(unused_imports)]
4902pub use send_more::*;
4903mod send_more_extended;
4904#[allow(unused_imports)]
4905pub use send_more_extended::*;
4906mod auth_cert;
4907#[allow(unused_imports)]
4908pub use auth_cert::*;
4909mod hello;
4910#[allow(unused_imports)]
4911pub use hello::*;
4912mod auth_msg_flag_flow_control_bytes_requested;
4913#[allow(unused_imports)]
4914pub use auth_msg_flag_flow_control_bytes_requested::*;
4915mod auth;
4916#[allow(unused_imports)]
4917pub use auth::*;
4918mod ip_addr_type;
4919#[allow(unused_imports)]
4920pub use ip_addr_type::*;
4921mod peer_address_ip;
4922#[allow(unused_imports)]
4923pub use peer_address_ip::*;
4924mod peer_address;
4925#[allow(unused_imports)]
4926pub use peer_address::*;
4927mod message_type;
4928#[allow(unused_imports)]
4929pub use message_type::*;
4930mod dont_have;
4931#[allow(unused_imports)]
4932pub use dont_have::*;
4933mod survey_message_command_type;
4934#[allow(unused_imports)]
4935pub use survey_message_command_type::*;
4936mod survey_message_response_type;
4937#[allow(unused_imports)]
4938pub use survey_message_response_type::*;
4939mod time_sliced_survey_start_collecting_message;
4940#[allow(unused_imports)]
4941pub use time_sliced_survey_start_collecting_message::*;
4942mod signed_time_sliced_survey_start_collecting_message;
4943#[allow(unused_imports)]
4944pub use signed_time_sliced_survey_start_collecting_message::*;
4945mod time_sliced_survey_stop_collecting_message;
4946#[allow(unused_imports)]
4947pub use time_sliced_survey_stop_collecting_message::*;
4948mod signed_time_sliced_survey_stop_collecting_message;
4949#[allow(unused_imports)]
4950pub use signed_time_sliced_survey_stop_collecting_message::*;
4951mod survey_request_message;
4952#[allow(unused_imports)]
4953pub use survey_request_message::*;
4954mod time_sliced_survey_request_message;
4955#[allow(unused_imports)]
4956pub use time_sliced_survey_request_message::*;
4957mod signed_time_sliced_survey_request_message;
4958#[allow(unused_imports)]
4959pub use signed_time_sliced_survey_request_message::*;
4960mod encrypted_body;
4961#[allow(unused_imports)]
4962pub use encrypted_body::*;
4963mod survey_response_message;
4964#[allow(unused_imports)]
4965pub use survey_response_message::*;
4966mod time_sliced_survey_response_message;
4967#[allow(unused_imports)]
4968pub use time_sliced_survey_response_message::*;
4969mod signed_time_sliced_survey_response_message;
4970#[allow(unused_imports)]
4971pub use signed_time_sliced_survey_response_message::*;
4972mod peer_stats;
4973#[allow(unused_imports)]
4974pub use peer_stats::*;
4975mod time_sliced_node_data;
4976#[allow(unused_imports)]
4977pub use time_sliced_node_data::*;
4978mod time_sliced_peer_data;
4979#[allow(unused_imports)]
4980pub use time_sliced_peer_data::*;
4981mod time_sliced_peer_data_list;
4982#[allow(unused_imports)]
4983pub use time_sliced_peer_data_list::*;
4984mod topology_response_body_v2;
4985#[allow(unused_imports)]
4986pub use topology_response_body_v2::*;
4987mod survey_response_body;
4988#[allow(unused_imports)]
4989pub use survey_response_body::*;
4990mod tx_advert_vector_max_size;
4991#[allow(unused_imports)]
4992pub use tx_advert_vector_max_size::*;
4993mod tx_advert_vector;
4994#[allow(unused_imports)]
4995pub use tx_advert_vector::*;
4996mod flood_advert;
4997#[allow(unused_imports)]
4998pub use flood_advert::*;
4999mod tx_demand_vector_max_size;
5000#[allow(unused_imports)]
5001pub use tx_demand_vector_max_size::*;
5002mod tx_demand_vector;
5003#[allow(unused_imports)]
5004pub use tx_demand_vector::*;
5005mod flood_demand;
5006#[allow(unused_imports)]
5007pub use flood_demand::*;
5008mod stellar_message;
5009#[allow(unused_imports)]
5010pub use stellar_message::*;
5011mod authenticated_message_v0;
5012#[allow(unused_imports)]
5013pub use authenticated_message_v0::*;
5014mod authenticated_message;
5015#[allow(unused_imports)]
5016pub use authenticated_message::*;
5017mod max_ops_per_tx;
5018#[allow(unused_imports)]
5019pub use max_ops_per_tx::*;
5020mod liquidity_pool_parameters;
5021#[allow(unused_imports)]
5022pub use liquidity_pool_parameters::*;
5023mod muxed_account_med25519;
5024#[allow(unused_imports)]
5025pub use muxed_account_med25519::*;
5026mod muxed_account;
5027#[allow(unused_imports)]
5028pub use muxed_account::*;
5029mod decorated_signature;
5030#[allow(unused_imports)]
5031pub use decorated_signature::*;
5032mod operation_type;
5033#[allow(unused_imports)]
5034pub use operation_type::*;
5035mod create_account_op;
5036#[allow(unused_imports)]
5037pub use create_account_op::*;
5038mod payment_op;
5039#[allow(unused_imports)]
5040pub use payment_op::*;
5041mod path_payment_strict_receive_op;
5042#[allow(unused_imports)]
5043pub use path_payment_strict_receive_op::*;
5044mod path_payment_strict_send_op;
5045#[allow(unused_imports)]
5046pub use path_payment_strict_send_op::*;
5047mod manage_sell_offer_op;
5048#[allow(unused_imports)]
5049pub use manage_sell_offer_op::*;
5050mod manage_buy_offer_op;
5051#[allow(unused_imports)]
5052pub use manage_buy_offer_op::*;
5053mod create_passive_sell_offer_op;
5054#[allow(unused_imports)]
5055pub use create_passive_sell_offer_op::*;
5056mod set_options_op;
5057#[allow(unused_imports)]
5058pub use set_options_op::*;
5059mod change_trust_asset;
5060#[allow(unused_imports)]
5061pub use change_trust_asset::*;
5062mod change_trust_op;
5063#[allow(unused_imports)]
5064pub use change_trust_op::*;
5065mod allow_trust_op;
5066#[allow(unused_imports)]
5067pub use allow_trust_op::*;
5068mod manage_data_op;
5069#[allow(unused_imports)]
5070pub use manage_data_op::*;
5071mod bump_sequence_op;
5072#[allow(unused_imports)]
5073pub use bump_sequence_op::*;
5074mod create_claimable_balance_op;
5075#[allow(unused_imports)]
5076pub use create_claimable_balance_op::*;
5077mod claim_claimable_balance_op;
5078#[allow(unused_imports)]
5079pub use claim_claimable_balance_op::*;
5080mod begin_sponsoring_future_reserves_op;
5081#[allow(unused_imports)]
5082pub use begin_sponsoring_future_reserves_op::*;
5083mod revoke_sponsorship_type;
5084#[allow(unused_imports)]
5085pub use revoke_sponsorship_type::*;
5086mod revoke_sponsorship_op_signer;
5087#[allow(unused_imports)]
5088pub use revoke_sponsorship_op_signer::*;
5089mod revoke_sponsorship_op;
5090#[allow(unused_imports)]
5091pub use revoke_sponsorship_op::*;
5092mod clawback_op;
5093#[allow(unused_imports)]
5094pub use clawback_op::*;
5095mod clawback_claimable_balance_op;
5096#[allow(unused_imports)]
5097pub use clawback_claimable_balance_op::*;
5098mod set_trust_line_flags_op;
5099#[allow(unused_imports)]
5100pub use set_trust_line_flags_op::*;
5101mod liquidity_pool_fee_v18;
5102#[allow(unused_imports)]
5103pub use liquidity_pool_fee_v18::*;
5104mod liquidity_pool_deposit_op;
5105#[allow(unused_imports)]
5106pub use liquidity_pool_deposit_op::*;
5107mod liquidity_pool_withdraw_op;
5108#[allow(unused_imports)]
5109pub use liquidity_pool_withdraw_op::*;
5110mod host_function_type;
5111#[allow(unused_imports)]
5112pub use host_function_type::*;
5113mod contract_id_preimage_type;
5114#[allow(unused_imports)]
5115pub use contract_id_preimage_type::*;
5116mod contract_id_preimage_from_address;
5117#[allow(unused_imports)]
5118pub use contract_id_preimage_from_address::*;
5119mod contract_id_preimage;
5120#[allow(unused_imports)]
5121pub use contract_id_preimage::*;
5122mod create_contract_args;
5123#[allow(unused_imports)]
5124pub use create_contract_args::*;
5125mod create_contract_args_v2;
5126#[allow(unused_imports)]
5127pub use create_contract_args_v2::*;
5128mod invoke_contract_args;
5129#[allow(unused_imports)]
5130pub use invoke_contract_args::*;
5131mod host_function;
5132#[allow(unused_imports)]
5133pub use host_function::*;
5134mod soroban_authorized_function_type;
5135#[allow(unused_imports)]
5136pub use soroban_authorized_function_type::*;
5137mod soroban_authorized_function;
5138#[allow(unused_imports)]
5139pub use soroban_authorized_function::*;
5140mod soroban_authorized_invocation;
5141#[allow(unused_imports)]
5142pub use soroban_authorized_invocation::*;
5143mod soroban_address_credentials;
5144#[allow(unused_imports)]
5145pub use soroban_address_credentials::*;
5146mod soroban_delegate_signature;
5147#[allow(unused_imports)]
5148pub use soroban_delegate_signature::*;
5149mod soroban_address_credentials_with_delegates;
5150#[allow(unused_imports)]
5151pub use soroban_address_credentials_with_delegates::*;
5152mod soroban_credentials_type;
5153#[allow(unused_imports)]
5154pub use soroban_credentials_type::*;
5155mod soroban_credentials;
5156#[allow(unused_imports)]
5157pub use soroban_credentials::*;
5158mod soroban_authorization_entry;
5159#[allow(unused_imports)]
5160pub use soroban_authorization_entry::*;
5161mod soroban_authorization_entries;
5162#[allow(unused_imports)]
5163pub use soroban_authorization_entries::*;
5164mod invoke_host_function_op;
5165#[allow(unused_imports)]
5166pub use invoke_host_function_op::*;
5167mod extend_footprint_ttl_op;
5168#[allow(unused_imports)]
5169pub use extend_footprint_ttl_op::*;
5170mod restore_footprint_op;
5171#[allow(unused_imports)]
5172pub use restore_footprint_op::*;
5173mod operation_body;
5174#[allow(unused_imports)]
5175pub use operation_body::*;
5176mod operation;
5177#[allow(unused_imports)]
5178pub use operation::*;
5179mod hash_id_preimage_operation_id;
5180#[allow(unused_imports)]
5181pub use hash_id_preimage_operation_id::*;
5182mod hash_id_preimage_revoke_id;
5183#[allow(unused_imports)]
5184pub use hash_id_preimage_revoke_id::*;
5185mod hash_id_preimage_contract_id;
5186#[allow(unused_imports)]
5187pub use hash_id_preimage_contract_id::*;
5188mod hash_id_preimage_soroban_authorization;
5189#[allow(unused_imports)]
5190pub use hash_id_preimage_soroban_authorization::*;
5191mod hash_id_preimage_soroban_authorization_with_address;
5192#[allow(unused_imports)]
5193pub use hash_id_preimage_soroban_authorization_with_address::*;
5194mod hash_id_preimage;
5195#[allow(unused_imports)]
5196pub use hash_id_preimage::*;
5197mod memo_type;
5198#[allow(unused_imports)]
5199pub use memo_type::*;
5200mod memo;
5201#[allow(unused_imports)]
5202pub use memo::*;
5203mod time_bounds;
5204#[allow(unused_imports)]
5205pub use time_bounds::*;
5206mod ledger_bounds;
5207#[allow(unused_imports)]
5208pub use ledger_bounds::*;
5209mod preconditions_v2;
5210#[allow(unused_imports)]
5211pub use preconditions_v2::*;
5212mod precondition_type;
5213#[allow(unused_imports)]
5214pub use precondition_type::*;
5215mod preconditions;
5216#[allow(unused_imports)]
5217pub use preconditions::*;
5218mod ledger_footprint;
5219#[allow(unused_imports)]
5220pub use ledger_footprint::*;
5221mod soroban_resources;
5222#[allow(unused_imports)]
5223pub use soroban_resources::*;
5224mod soroban_resources_ext_v0;
5225#[allow(unused_imports)]
5226pub use soroban_resources_ext_v0::*;
5227mod soroban_transaction_data_ext;
5228#[allow(unused_imports)]
5229pub use soroban_transaction_data_ext::*;
5230mod soroban_transaction_data;
5231#[allow(unused_imports)]
5232pub use soroban_transaction_data::*;
5233mod transaction_v0_ext;
5234#[allow(unused_imports)]
5235pub use transaction_v0_ext::*;
5236mod transaction_v0;
5237#[allow(unused_imports)]
5238pub use transaction_v0::*;
5239mod transaction_v0_envelope;
5240#[allow(unused_imports)]
5241pub use transaction_v0_envelope::*;
5242mod transaction_ext;
5243#[allow(unused_imports)]
5244pub use transaction_ext::*;
5245mod transaction;
5246#[allow(unused_imports)]
5247pub use transaction::*;
5248mod transaction_v1_envelope;
5249#[allow(unused_imports)]
5250pub use transaction_v1_envelope::*;
5251mod fee_bump_transaction_inner_tx;
5252#[allow(unused_imports)]
5253pub use fee_bump_transaction_inner_tx::*;
5254mod fee_bump_transaction_ext;
5255#[allow(unused_imports)]
5256pub use fee_bump_transaction_ext::*;
5257mod fee_bump_transaction;
5258#[allow(unused_imports)]
5259pub use fee_bump_transaction::*;
5260mod fee_bump_transaction_envelope;
5261#[allow(unused_imports)]
5262pub use fee_bump_transaction_envelope::*;
5263mod transaction_envelope;
5264#[allow(unused_imports)]
5265pub use transaction_envelope::*;
5266mod transaction_signature_payload_tagged_transaction;
5267#[allow(unused_imports)]
5268pub use transaction_signature_payload_tagged_transaction::*;
5269mod transaction_signature_payload;
5270#[allow(unused_imports)]
5271pub use transaction_signature_payload::*;
5272mod claim_atom_type;
5273#[allow(unused_imports)]
5274pub use claim_atom_type::*;
5275mod claim_offer_atom_v0;
5276#[allow(unused_imports)]
5277pub use claim_offer_atom_v0::*;
5278mod claim_offer_atom;
5279#[allow(unused_imports)]
5280pub use claim_offer_atom::*;
5281mod claim_liquidity_atom;
5282#[allow(unused_imports)]
5283pub use claim_liquidity_atom::*;
5284mod claim_atom;
5285#[allow(unused_imports)]
5286pub use claim_atom::*;
5287mod create_account_result_code;
5288#[allow(unused_imports)]
5289pub use create_account_result_code::*;
5290mod create_account_result;
5291#[allow(unused_imports)]
5292pub use create_account_result::*;
5293mod payment_result_code;
5294#[allow(unused_imports)]
5295pub use payment_result_code::*;
5296mod payment_result;
5297#[allow(unused_imports)]
5298pub use payment_result::*;
5299mod path_payment_strict_receive_result_code;
5300#[allow(unused_imports)]
5301pub use path_payment_strict_receive_result_code::*;
5302mod simple_payment_result;
5303#[allow(unused_imports)]
5304pub use simple_payment_result::*;
5305mod path_payment_strict_receive_result_success;
5306#[allow(unused_imports)]
5307pub use path_payment_strict_receive_result_success::*;
5308mod path_payment_strict_receive_result;
5309#[allow(unused_imports)]
5310pub use path_payment_strict_receive_result::*;
5311mod path_payment_strict_send_result_code;
5312#[allow(unused_imports)]
5313pub use path_payment_strict_send_result_code::*;
5314mod path_payment_strict_send_result_success;
5315#[allow(unused_imports)]
5316pub use path_payment_strict_send_result_success::*;
5317mod path_payment_strict_send_result;
5318#[allow(unused_imports)]
5319pub use path_payment_strict_send_result::*;
5320mod manage_sell_offer_result_code;
5321#[allow(unused_imports)]
5322pub use manage_sell_offer_result_code::*;
5323mod manage_offer_effect;
5324#[allow(unused_imports)]
5325pub use manage_offer_effect::*;
5326mod manage_offer_success_result_offer;
5327#[allow(unused_imports)]
5328pub use manage_offer_success_result_offer::*;
5329mod manage_offer_success_result;
5330#[allow(unused_imports)]
5331pub use manage_offer_success_result::*;
5332mod manage_sell_offer_result;
5333#[allow(unused_imports)]
5334pub use manage_sell_offer_result::*;
5335mod manage_buy_offer_result_code;
5336#[allow(unused_imports)]
5337pub use manage_buy_offer_result_code::*;
5338mod manage_buy_offer_result;
5339#[allow(unused_imports)]
5340pub use manage_buy_offer_result::*;
5341mod set_options_result_code;
5342#[allow(unused_imports)]
5343pub use set_options_result_code::*;
5344mod set_options_result;
5345#[allow(unused_imports)]
5346pub use set_options_result::*;
5347mod change_trust_result_code;
5348#[allow(unused_imports)]
5349pub use change_trust_result_code::*;
5350mod change_trust_result;
5351#[allow(unused_imports)]
5352pub use change_trust_result::*;
5353mod allow_trust_result_code;
5354#[allow(unused_imports)]
5355pub use allow_trust_result_code::*;
5356mod allow_trust_result;
5357#[allow(unused_imports)]
5358pub use allow_trust_result::*;
5359mod account_merge_result_code;
5360#[allow(unused_imports)]
5361pub use account_merge_result_code::*;
5362mod account_merge_result;
5363#[allow(unused_imports)]
5364pub use account_merge_result::*;
5365mod inflation_result_code;
5366#[allow(unused_imports)]
5367pub use inflation_result_code::*;
5368mod inflation_payout;
5369#[allow(unused_imports)]
5370pub use inflation_payout::*;
5371mod inflation_result;
5372#[allow(unused_imports)]
5373pub use inflation_result::*;
5374mod manage_data_result_code;
5375#[allow(unused_imports)]
5376pub use manage_data_result_code::*;
5377mod manage_data_result;
5378#[allow(unused_imports)]
5379pub use manage_data_result::*;
5380mod bump_sequence_result_code;
5381#[allow(unused_imports)]
5382pub use bump_sequence_result_code::*;
5383mod bump_sequence_result;
5384#[allow(unused_imports)]
5385pub use bump_sequence_result::*;
5386mod create_claimable_balance_result_code;
5387#[allow(unused_imports)]
5388pub use create_claimable_balance_result_code::*;
5389mod create_claimable_balance_result;
5390#[allow(unused_imports)]
5391pub use create_claimable_balance_result::*;
5392mod claim_claimable_balance_result_code;
5393#[allow(unused_imports)]
5394pub use claim_claimable_balance_result_code::*;
5395mod claim_claimable_balance_result;
5396#[allow(unused_imports)]
5397pub use claim_claimable_balance_result::*;
5398mod begin_sponsoring_future_reserves_result_code;
5399#[allow(unused_imports)]
5400pub use begin_sponsoring_future_reserves_result_code::*;
5401mod begin_sponsoring_future_reserves_result;
5402#[allow(unused_imports)]
5403pub use begin_sponsoring_future_reserves_result::*;
5404mod end_sponsoring_future_reserves_result_code;
5405#[allow(unused_imports)]
5406pub use end_sponsoring_future_reserves_result_code::*;
5407mod end_sponsoring_future_reserves_result;
5408#[allow(unused_imports)]
5409pub use end_sponsoring_future_reserves_result::*;
5410mod revoke_sponsorship_result_code;
5411#[allow(unused_imports)]
5412pub use revoke_sponsorship_result_code::*;
5413mod revoke_sponsorship_result;
5414#[allow(unused_imports)]
5415pub use revoke_sponsorship_result::*;
5416mod clawback_result_code;
5417#[allow(unused_imports)]
5418pub use clawback_result_code::*;
5419mod clawback_result;
5420#[allow(unused_imports)]
5421pub use clawback_result::*;
5422mod clawback_claimable_balance_result_code;
5423#[allow(unused_imports)]
5424pub use clawback_claimable_balance_result_code::*;
5425mod clawback_claimable_balance_result;
5426#[allow(unused_imports)]
5427pub use clawback_claimable_balance_result::*;
5428mod set_trust_line_flags_result_code;
5429#[allow(unused_imports)]
5430pub use set_trust_line_flags_result_code::*;
5431mod set_trust_line_flags_result;
5432#[allow(unused_imports)]
5433pub use set_trust_line_flags_result::*;
5434mod liquidity_pool_deposit_result_code;
5435#[allow(unused_imports)]
5436pub use liquidity_pool_deposit_result_code::*;
5437mod liquidity_pool_deposit_result;
5438#[allow(unused_imports)]
5439pub use liquidity_pool_deposit_result::*;
5440mod liquidity_pool_withdraw_result_code;
5441#[allow(unused_imports)]
5442pub use liquidity_pool_withdraw_result_code::*;
5443mod liquidity_pool_withdraw_result;
5444#[allow(unused_imports)]
5445pub use liquidity_pool_withdraw_result::*;
5446mod invoke_host_function_result_code;
5447#[allow(unused_imports)]
5448pub use invoke_host_function_result_code::*;
5449mod invoke_host_function_result;
5450#[allow(unused_imports)]
5451pub use invoke_host_function_result::*;
5452mod extend_footprint_ttl_result_code;
5453#[allow(unused_imports)]
5454pub use extend_footprint_ttl_result_code::*;
5455mod extend_footprint_ttl_result;
5456#[allow(unused_imports)]
5457pub use extend_footprint_ttl_result::*;
5458mod restore_footprint_result_code;
5459#[allow(unused_imports)]
5460pub use restore_footprint_result_code::*;
5461mod restore_footprint_result;
5462#[allow(unused_imports)]
5463pub use restore_footprint_result::*;
5464mod operation_result_code;
5465#[allow(unused_imports)]
5466pub use operation_result_code::*;
5467mod operation_result_tr;
5468#[allow(unused_imports)]
5469pub use operation_result_tr::*;
5470mod operation_result;
5471#[allow(unused_imports)]
5472pub use operation_result::*;
5473mod transaction_result_code;
5474#[allow(unused_imports)]
5475pub use transaction_result_code::*;
5476mod inner_transaction_result_result;
5477#[allow(unused_imports)]
5478pub use inner_transaction_result_result::*;
5479mod inner_transaction_result_ext;
5480#[allow(unused_imports)]
5481pub use inner_transaction_result_ext::*;
5482mod inner_transaction_result;
5483#[allow(unused_imports)]
5484pub use inner_transaction_result::*;
5485mod inner_transaction_result_pair;
5486#[allow(unused_imports)]
5487pub use inner_transaction_result_pair::*;
5488mod transaction_result_result;
5489#[allow(unused_imports)]
5490pub use transaction_result_result::*;
5491mod transaction_result_ext;
5492#[allow(unused_imports)]
5493pub use transaction_result_ext::*;
5494mod transaction_result;
5495#[allow(unused_imports)]
5496pub use transaction_result::*;
5497mod hash;
5498#[allow(unused_imports)]
5499pub use hash::*;
5500mod uint256;
5501#[allow(unused_imports)]
5502pub use uint256::*;
5503mod uint32;
5504#[allow(unused_imports)]
5505pub use uint32::*;
5506mod int32;
5507#[allow(unused_imports)]
5508pub use int32::*;
5509mod uint64;
5510#[allow(unused_imports)]
5511pub use uint64::*;
5512mod int64;
5513#[allow(unused_imports)]
5514pub use int64::*;
5515mod time_point;
5516#[allow(unused_imports)]
5517pub use time_point::*;
5518mod duration;
5519#[allow(unused_imports)]
5520pub use duration::*;
5521mod extension_point;
5522#[allow(unused_imports)]
5523pub use extension_point::*;
5524mod crypto_key_type;
5525#[allow(unused_imports)]
5526pub use crypto_key_type::*;
5527mod public_key_type;
5528#[allow(unused_imports)]
5529pub use public_key_type::*;
5530mod signer_key_type;
5531#[allow(unused_imports)]
5532pub use signer_key_type::*;
5533mod public_key;
5534#[allow(unused_imports)]
5535pub use public_key::*;
5536mod signer_key_ed25519_signed_payload;
5537#[allow(unused_imports)]
5538pub use signer_key_ed25519_signed_payload::*;
5539mod signer_key;
5540#[allow(unused_imports)]
5541pub use signer_key::*;
5542mod signature;
5543#[allow(unused_imports)]
5544pub use signature::*;
5545mod signature_hint;
5546#[allow(unused_imports)]
5547pub use signature_hint::*;
5548mod node_id;
5549#[allow(unused_imports)]
5550pub use node_id::*;
5551mod account_id;
5552#[allow(unused_imports)]
5553pub use account_id::*;
5554mod contract_id;
5555#[allow(unused_imports)]
5556pub use contract_id::*;
5557mod curve25519_secret;
5558#[allow(unused_imports)]
5559pub use curve25519_secret::*;
5560mod curve25519_public;
5561#[allow(unused_imports)]
5562pub use curve25519_public::*;
5563mod hmac_sha256_key;
5564#[allow(unused_imports)]
5565pub use hmac_sha256_key::*;
5566mod hmac_sha256_mac;
5567#[allow(unused_imports)]
5568pub use hmac_sha256_mac::*;
5569mod short_hash_seed;
5570#[allow(unused_imports)]
5571pub use short_hash_seed::*;
5572mod binary_fuse_filter_type;
5573#[allow(unused_imports)]
5574pub use binary_fuse_filter_type::*;
5575mod serialized_binary_fuse_filter;
5576#[allow(unused_imports)]
5577pub use serialized_binary_fuse_filter::*;
5578mod pool_id;
5579#[allow(unused_imports)]
5580pub use pool_id::*;
5581mod claimable_balance_id_type;
5582#[allow(unused_imports)]
5583pub use claimable_balance_id_type::*;
5584mod claimable_balance_id;
5585#[allow(unused_imports)]
5586pub use claimable_balance_id::*;
5587mod test_next_type;
5588#[allow(unused_imports)]
5589pub use test_next_type::*;
5590mod type_enum;
5591#[allow(unused_imports)]
5592pub use type_enum::*;