Expand description
Read and write the git packet line wire format without copying it.
§Examples
use std::io::Write;
use gix_packetline::{
blocking_io::{encode, StreamingPeekableIter, Writer},
PacketLineRef,
};
let mut writer = Writer::new(Vec::new());
writer.enable_text_mode();
writer.write_all(b"command=ls-refs")?;
writer.write_all(b"agent=gitoxide")?;
encode::flush_to_write(writer.inner_mut())?;
let bytes = writer.into_inner();
let mut reader = StreamingPeekableIter::new(&bytes[..], &[PacketLineRef::Flush], false);
assert_eq!(
reader.read_line().unwrap()??.as_text().unwrap().as_bstr(),
"command=ls-refs"
);
assert_eq!(
reader.read_line().unwrap()??.as_text().unwrap().as_bstr(),
"agent=gitoxide"
);
assert!(reader.read_line().is_none());
assert_eq!(reader.stopped_at(), Some(PacketLineRef::Flush));§Feature Flags
By default, all IO related capabilities will be missing unless one of the following is chosen.
blocking-io— Enable blocking I/O API.async-io— Enable async I/O API using IO traits fromfutures-io.
§Other
serde— Data structures implementserde::Serializeandserde::Deserialize.
Modules§
- blocking_
io blocking-io - decode
- Utilities to help decoding packet lines
- encode
- Utilities to encode different kinds of packet lines
- read
- Various utilities for
io::Readtrait implementation.
Structs§
- Error
Ref - A packet line representing an Error in a sideband channel.
- TextRef
- A packet line representing text, which may include a trailing newline.
Enums§
- BandRef
- A band in a sideband channel.
- Channel
- One of three sideband types allowing to multiplex information over a single connection.
- Packet
Line Ref - A borrowed packet line as it refers to a slice of data by reference.
Functions§
- decode
- Decode an entire packet line from data or fail.