pub struct FallibleHexd<R: ReadBytes> { /* private fields */ }Expand description
A fallible variant of Hexd that surfaces errors from the underlying reader.
Implementations§
Source§impl<R: ReadBytes> FallibleHexd<R>
impl<R: ReadBytes> FallibleHexd<R>
Sourcepub fn new(reader: R) -> Self
pub fn new(reader: R) -> Self
Construct a new Hexd instance with the given reader and default options.
Sourcepub fn new_with_options(reader: R, options: HexdOptions) -> Self
pub fn new_with_options(reader: R, options: HexdOptions) -> Self
Construct a new Hexd instance with the given reader and options.
Sourcepub fn dump(self) -> Result<(), R::Error>
pub fn dump(self) -> Result<(), R::Error>
Print a hexdump to stdout.
use hxd::IntoFallibleHexd;
use std::fs::OpenOptions;
let f = OpenOptions::new().read(true).open("file.txt").unwrap();
f.hexd().dump().expect("could not read file"); // print a hexdumpSourcepub fn dump_err(self) -> Result<(), R::Error>
pub fn dump_err(self) -> Result<(), R::Error>
Print a hexdump to stderr.
use hxd::IntoFallibleHexd;
use std::fs::OpenOptions;
let f = OpenOptions::new().read(true).open("file.txt").unwrap();
f.hexd().dump_err().expect("could not read file"); // print a hexdump to stderrSourcepub fn dump_to<W: WriteHexdump + Default>(self) -> Result<W::Output, R::Error>
pub fn dump_to<W: WriteHexdump + Default>(self) -> Result<W::Output, R::Error>
Construct a default instance of W and write a hexdump to it, returning its output.
use hxd::IntoFallibleHexd;
use std::fs::OpenOptions;
let f = OpenOptions::new().read(true).open("file.txt").unwrap();
let dump = f.hexd().dump_to::<String>().expect("could not read file");Sourcepub fn dump_into<W: WriteHexdump>(
self,
writer: W,
) -> Result<W::Output, R::Error>
pub fn dump_into<W: WriteHexdump>( self, writer: W, ) -> Result<W::Output, R::Error>
Write a hexdump to an instance of W and return its output.
use hxd::IntoFallibleHexd;
use std::fs::OpenOptions;
let f = OpenOptions::new().read(true).open("file.txt").unwrap();
let v: Vec<String> = Vec::new();
let dump = f.hexd().dump_into(v).expect("could not read file");Sourcepub fn dump_io<W: Write>(
self,
write: W,
) -> Result<(), ReadWriteError<R::Error, Error>>
pub fn dump_io<W: Write>( self, write: W, ) -> Result<(), ReadWriteError<R::Error, Error>>
Write a hexdump to an object that is Write. The object is wrapped in a BufWriter for improved performance.
use hxd::{IntoFallibleHexd, ReadWriteError};
use std::fs::OpenOptions;
let src = OpenOptions::new().read(true).open("file.txt").unwrap();
let f = OpenOptions::new()
.write(true)
.create(true)
.open("hexdump.txt")
.unwrap();
src.hexd().dump_io(f).map_err(|err| match err {
ReadWriteError::Read(e) => panic!("could not read file: {:?}", e),
ReadWriteError::Write(e) => panic!("could not write to file: {:?}", e),
});Sourcepub fn dump_io_unbuffered<W: Write>(
self,
write: W,
) -> Result<(), ReadWriteError<R::Error, Error>>
pub fn dump_io_unbuffered<W: Write>( self, write: W, ) -> Result<(), ReadWriteError<R::Error, Error>>
Write a hexdump to an object that is Write.
Unlike Self::dump_io, this method does not wrap the object in a
BufWriter.
use hxd::{IntoFallibleHexd, ReadWriteError};
use std::fs::OpenOptions;
let src = OpenOptions::new().read(true).open("file.txt").unwrap();
let f = OpenOptions::new()
.write(true)
.create(true)
.open("hexdump.txt")
.unwrap();
src.hexd().dump_io_unbuffered(f).map_err(|err| match err {
ReadWriteError::Read(e) => panic!("could not read file: {:?}", e),
ReadWriteError::Write(e) => panic!("could not write to file: {:?}", e),
});Trait Implementations§
Source§impl<R: ReadBytes> HexdOptionsBuilder for FallibleHexd<R>
FallibleHexd implements HexdOptionsBuilder to allow for fluent
configuration.
impl<R: ReadBytes> HexdOptionsBuilder for FallibleHexd<R>
FallibleHexd implements HexdOptionsBuilder to allow for fluent
configuration.
Source§fn map_options<F: FnOnce(HexdOptions) -> HexdOptions>(self, f: F) -> Self
fn map_options<F: FnOnce(HexdOptions) -> HexdOptions>(self, f: F) -> Self
Return a new instance of
Self with the mapping function applied
to the instance’s options.Source§fn with_options(self, o: HexdOptions) -> Self
fn with_options(self, o: HexdOptions) -> Self
Return a new instance of
Self with the given options.Source§fn base(self, base: Base) -> Self
fn base(self, base: Base) -> Self
Set the base system to use.
This is equivalent to setting the value of the
base field.Source§fn hexadecimal(self) -> Self
fn hexadecimal(self) -> Self
Set the base system to hexadecimal and the grouping to the default. Read more
Source§fn decimal(self) -> Self
fn decimal(self) -> Self
Set the base system to decimal with spaces rendered for leading zeroes.
Set the grouping to 8 equivalently spaced bytes. Read more
Source§fn octal(self) -> Self
fn octal(self) -> Self
Set the base system to octal with leading zeroes included.
Set the grouping to 8 equivalently spaced bytes. Read more
Source§fn binary(self) -> Self
fn binary(self) -> Self
Set the base system to binary with spaces rendered for leading zeroes.
Set the grouping 4 equivalently spaced bytes. Read more
Source§fn range<R: RangeBounds<usize>>(self, range: R) -> Self
fn range<R: RangeBounds<usize>>(self, range: R) -> Self
Set a range of bytes to dump.
This is equivalent to setting the value of the
print_range field.Source§fn show_ascii(self, show_ascii: bool) -> Self
fn show_ascii(self, show_ascii: bool) -> Self
Set the value of the
show_ascii field.Source§fn show_index(self, show_index: bool) -> Self
fn show_index(self, show_index: bool) -> Self
Set the value of the
show_index field.Source§fn ungrouped(self, num_bytes: usize, spacing: Spacing) -> Self
fn ungrouped(self, num_bytes: usize, spacing: Spacing) -> Self
Set the value of the
grouping field to Grouping::Ungrouped
using the specified parameters.Source§fn grouped(
self,
(group_size, byte_spacing): (GroupSize, Spacing),
(num_groups, group_spacing): (usize, Spacing),
) -> Self
fn grouped( self, (group_size, byte_spacing): (GroupSize, Spacing), (num_groups, group_spacing): (usize, Spacing), ) -> Self
Set the value of the
grouping field to Grouping::Grouped
using the specified parameters.Source§fn grouped_by(self, group_size: GroupSize, num_groups: usize) -> Self
fn grouped_by(self, group_size: GroupSize, num_groups: usize) -> Self
Set the value of the
grouping field to Grouping::Grouped
using the specified parameters and default spacing.
This is equivalent to calling grouped with the arguments
(GroupSize::Short, Spacing::None) and (num_groups, Spacing::Normal).Source§fn offset(self, index_offset: IndexOffset) -> Self
fn offset(self, index_offset: IndexOffset) -> Self
Set the value of the
index_offset field.Source§fn relative_offset(self, offset: usize) -> Self
fn relative_offset(self, offset: usize) -> Self
Set the value of the
index_offset field to IndexOffset::Relative.Source§fn absolute_offset(self, offset: usize) -> Self
fn absolute_offset(self, offset: usize) -> Self
Set the value of the
index_offset field to IndexOffset::Absolute.Auto Trait Implementations§
impl<R> Freeze for FallibleHexd<R>where
R: Freeze,
impl<R> RefUnwindSafe for FallibleHexd<R>where
R: RefUnwindSafe,
impl<R> Send for FallibleHexd<R>where
R: Send,
impl<R> Sync for FallibleHexd<R>where
R: Sync,
impl<R> Unpin for FallibleHexd<R>where
R: Unpin,
impl<R> UnwindSafe for FallibleHexd<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more