]> git.proxmox.com Git - rustc.git/blob - vendor/gix-packetline/src/encode/mod.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / vendor / gix-packetline / src / encode / mod.rs
1 use crate::MAX_DATA_LEN;
2
3 /// The error returned by most functions in the [`encode`][crate::encode] module
4 #[derive(Debug, thiserror::Error)]
5 #[allow(missing_docs)]
6 pub enum Error {
7 #[error("Cannot encode more than {MAX_DATA_LEN} bytes, got {length_in_bytes}")]
8 DataLengthLimitExceeded { length_in_bytes: usize },
9 #[error("Empty lines are invalid")]
10 DataIsEmpty,
11 }
12
13 #[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
14 mod async_io;
15 #[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
16 pub use async_io::*;
17
18 #[cfg(feature = "blocking-io")]
19 mod blocking_io;
20 #[cfg(feature = "blocking-io")]
21 pub use blocking_io::*;
22
23 pub(crate) fn u16_to_hex(value: u16) -> [u8; 4] {
24 let mut buf = [0u8; 4];
25 faster_hex::hex_encode(&value.to_be_bytes(), &mut buf).expect("two bytes to 4 hex chars never fails");
26 buf
27 }