1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! # The seqbytes library
//! The seqbytes crate provides the traits `ESeqByteReader` and `SeqByteReader` used for reading bytes sequentially. The `SeqByteReader` trait convert the bytes into the
//! specified generic type, denoted `U`, which must implement `SizedNumber`. The trait `SizedNumber` represents a type which can be converted to and from bytes, with a
//! fixed size in bytes.
//!
//! The trait `ESeqByteReader` is used for reading bytes sequentially, converting to a type with a specific endianness. The type converted to must implement `EndianNumber`,
//! which represents a type which can be converted to and from bytes with a specific endianness.
//!
//! # Implementation
//! The traits `E$eqByteReader` and `SeqByteReader` are implemented by default on types implementing `Read` + `Seek`.
//!
//! ## Example 1
//! Using [`SizedNumber`] trait to convert numbers.
//! ```
//! use seqbytes::traits::*;
//!
//! let a = 22.4f64;
//! let b = a.to_bytes();
//! let c = f64::from_bytes(&b);
//! let d = u32::from_bytes(&[2, 4, 6]);
//! assert_eq!(c, Some(22.4));
//! assert_eq!(d, None);
//! ```
//! ## Example 2
//! Using [`seqbytes::bytes::SeqByteReader`] trait to read a Vector sequentially
//! ```
//! use seqbytes::prelude::*;
//! use std::io::Cursor;
//! use std::str::FromStr;
//!
//! let a = vec![69, 96, 255, 255, 0x68, 0x65, 0x6C, 0x6C, 0x6F];
//! let mut cursor = Cursor::new(a);
//!
//! let num : i32 = cursor.shift().unwrap();
//! let s = &*cursor.shift_string(5).unwrap();
//!
//! assert_eq!(num, -40891);
//! assert_eq!(*s, *"hello");
//! ```
/// Contains the traits [`seqbytes::bytes::SeqByteReader`] and [`seqbytes::bytes::ESeqByteReader`]
/// Re-exports everything from the module [`seqbytes::bytes`] and [`seqbytes::traits`]
/// Contains all traits in this library.