Struct edhex_core::State
source · [−]pub struct State {
pub prefs: Preferences,
pub unsaved_changes: bool,
pub filename: String,
pub readonly: bool,
pub last_search: Option<Vec<u8>>,
pub index: usize,
pub all_bytes: Vec<u8>,
pub breaks: HashSet<usize>,
}
Fields
prefs: Preferences
unsaved_changes: bool
filename: String
readonly: bool
last_search: Option<Vec<u8>>
index: usize
all_bytes: Vec<u8>
breaks: HashSet<usize>
Implementations
sourceimpl State
impl State
pub fn pretty_color_state(&self) -> String
sourcepub fn addresses(&self, from: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn addresses(&self, from: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return the byte numbers necessary for the left column of a display
pub fn read_from_filename(filename: &str) -> Result<Self, String>
sourcepub fn read_from_path(path: &Path) -> Result<Self, String>
pub fn read_from_path(path: &Path) -> Result<Self, String>
Note: For the forseeable future, from_reader is actually slower than drawing the entire file into memory. So until that changes, doing the latter: https://github.com/serde-rs/json/issues/160
sourcepub fn bytes_range_from(&self, address: usize) -> Range<usize>
pub fn bytes_range_from(&self, address: usize) -> Range<usize>
Return the range self.prefs.width
bytes starting at address
.
Could be cut short by hitting end of all bytes.
Could be empty because address
is past end of all bytes.
sourcepub fn bytes_from(&self, address: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn bytes_from(&self, address: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Print self.prefs.width
bytes from address
or cut off if at end of all bytes
pub fn bytes_from_current_row(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn current_row_string(&self) -> String
sourcepub fn line_with_break(
&self,
begin: usize,
end: usize,
underline: bool
) -> Option<(String, usize)>
pub fn line_with_break(
&self,
begin: usize,
end: usize,
underline: bool
) -> Option<(String, usize)>
Returns the line to print and the index of the last byte printed
pub fn bytes_line(
&self,
bytes: &[u8],
line_number: usize,
underline: bool
) -> String
pub fn bytes_line_padding(&self, bytes: &[u8], line_num: usize) -> String
sourcepub fn range_from_current_row(&self) -> Result<(usize, usize), String>
pub fn range_from_current_row(&self) -> Result<(usize, usize), String>
Return the range for the bytes in the current row
sourcepub fn last_byte_of_row_index(&self) -> Result<usize, String>
pub fn last_byte_of_row_index(&self) -> Result<usize, String>
In current row, what’s the index of the last byte to show?
pub fn print_bytes_and_move_index(&mut self)
pub fn index_of_byte_after(&self, index: usize) -> Option<usize>
pub fn index_of_byte_before(&self, index: usize) -> Option<usize>
pub fn index_of_prev_byte(&self) -> Option<usize>
pub fn index_of_next_byte(&self) -> Option<usize>
pub fn index_of_next_line(&self) -> Option<usize>
pub fn move_index_then_print_bytes(&mut self)
pub fn before_context_lines(&self) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn after_context_lines(
&self,
first_after_context_index: usize,
max_index: usize
) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn print_bytes(&self, underline_main_bytes: bool) -> Option<usize>
pub fn print_bytes(&self, underline_main_bytes: bool) -> Option<usize>
returns index of the last byte printed in the non-context line
pub fn byte_indices_between(
&self,
range: (usize, usize)
) -> Option<(usize, usize)>
pub fn bytes_in_range(&self, range: (usize, usize)) -> Result<&[u8], String>
sourcepub fn print_bytes_sans_context(&self, range: (usize, usize)) -> Option<usize>
pub fn print_bytes_sans_context(&self, range: (usize, usize)) -> Option<usize>
returns index of the first byte printed on the last line
This is more primitive than print_bytes
. It just prints the bytes
from the range.
pub fn empty(&self) -> bool
pub fn range(&self) -> (usize, usize)
pub fn max_index(&self) -> Result<usize, String>
Trait Implementations
sourceimpl DiskWritable for &State
impl DiskWritable for &State
sourcefn write_to_disk(self, filename: &str) -> Result<(), String>
fn write_to_disk(self, filename: &str) -> Result<(), String>
Serialize to a json blob. Don’t include all_bytes, not only because it could be huge, but because if you load a state from disk and its bytes differ from the actual file’s on disk bytes, neither collection of bytes are canonical. User’s can write out bytes to other files at will.
sourceimpl From<&'_ State> for StateSansBytes
impl From<&'_ State> for StateSansBytes
sourceimpl From<&'_ StateSansBytes> for State
impl From<&'_ StateSansBytes> for State
sourcefn from(state_sans_bytes: &StateSansBytes) -> Self
fn from(state_sans_bytes: &StateSansBytes) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more