gix_packetline_blocking/
lib.rs#![cfg_attr(
all(doc, all(doc, feature = "document-features")),
doc = ::document_features::document_features!()
)]
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
const U16_HEX_BYTES: usize = 4;
const MAX_DATA_LEN: usize = 65516;
const MAX_LINE_LEN: usize = MAX_DATA_LEN + U16_HEX_BYTES;
const FLUSH_LINE: &[u8] = b"0000";
const DELIMITER_LINE: &[u8] = b"0001";
const RESPONSE_END_LINE: &[u8] = b"0002";
const ERR_PREFIX: &[u8] = b"ERR ";
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Channel {
Data = 1,
Progress = 2,
Error = 3,
}
mod line;
pub mod read;
#[cfg(any(feature = "async-io", feature = "blocking-io"))]
mod write;
#[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
pub use write::async_io::Writer;
#[cfg(feature = "blocking-io")]
pub use write::blocking_io::Writer;
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PacketLineRef<'a> {
Data(&'a [u8]),
Flush,
Delimiter,
ResponseEnd,
}
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ErrorRef<'a>(pub &'a [u8]);
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TextRef<'a>(pub &'a [u8]);
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum BandRef<'a> {
Data(&'a [u8]),
Progress(&'a [u8]),
Error(&'a [u8]),
}
pub struct StreamingPeekableIter<T> {
read: T,
peek_buf: Vec<u8>,
#[cfg(any(feature = "blocking-io", feature = "async-io"))]
buf: Vec<u8>,
fail_on_err_lines: bool,
delimiters: &'static [PacketLineRef<'static>],
is_done: bool,
stopped_at: Option<PacketLineRef<'static>>,
#[cfg_attr(all(not(feature = "async-io"), not(feature = "blocking-io")), allow(dead_code))]
trace: bool,
}
pub mod decode;
#[doc(inline)]
pub use decode::all_at_once as decode;
pub mod encode;
#[cfg(all(feature = "async-io", feature = "blocking-io"))]
compile_error!("Cannot set both 'blocking-io' and 'async-io' features as they are mutually exclusive");