[−][src]Struct sequoia_openpgp::fmt::hex::Dumper
Writes annotated hex dumps, like hd(1).
Examples
use sequoia_openpgp::fmt::hex; let mut dumper = hex::Dumper::new(Vec::new(), ""); dumper.write(&[0x89, 0x01, 0x33], "frame")?; dumper.write(&[0x04], "version")?; dumper.write(&[0x00], "type")?; let buf = dumper.into_inner(); assert_eq!( ::std::str::from_utf8(&buf[..])?, "00000000 89 01 33 frame\n\ 00000003 04 version\n\ 00000004 00 type\n\ ");
Implementations
impl<W: Write> Dumper<W>
[src]
pub fn new<I: AsRef<str>>(inner: W, indent: I) -> Self
[src]
Creates a new dumper.
The dump is written to inner
. Every line is indented with
indent
.
pub fn into_inner(self) -> W
[src]
Returns the inner writer.
pub fn write<B, M>(&mut self, buf: B, msg: M) -> Result<()> where
B: AsRef<[u8]>,
M: AsRef<str>,
[src]
B: AsRef<[u8]>,
M: AsRef<str>,
Writes a chunk of data.
The msg
is printed at the end of the first line.
pub fn write_ascii<B>(&mut self, buf: B) -> Result<()> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
Writes a chunk of data with ASCII-representation.
This produces output similar to hd(1)
.
pub fn write_labeled<B, L>(&mut self, buf: B, labeler: L) -> Result<()> where
B: AsRef<[u8]>,
L: FnMut(usize, &[u8]) -> Option<String>,
[src]
B: AsRef<[u8]>,
L: FnMut(usize, &[u8]) -> Option<String>,
Writes a chunk of data.
For each line, the given function is called to compute a label that printed at the end of the first line. The functions first argument is the offset in the current line (0..16), the second the slice of the displayed data.
Auto Trait Implementations
impl<W> RefUnwindSafe for Dumper<W> where
W: RefUnwindSafe,
[src]
W: RefUnwindSafe,
impl<W> Send for Dumper<W> where
W: Send,
[src]
W: Send,
impl<W> Sync for Dumper<W> where
W: Sync,
[src]
W: Sync,
impl<W> Unpin for Dumper<W> where
W: Unpin,
[src]
W: Unpin,
impl<W> UnwindSafe for Dumper<W> where
W: UnwindSafe,
[src]
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,