gix_packetline/encode/
mod.rs1use crate::MAX_DATA_LEN;
2
3#[derive(Debug, thiserror::Error)]
5#[allow(missing_docs)]
6pub 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"))]
14mod async_io;
15#[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
16pub use async_io::*;
17
18#[cfg(feature = "blocking-io")]
19mod blocking_io;
20#[cfg(feature = "blocking-io")]
21pub use blocking_io::*;
22
23pub(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}