pub struct MemoryEditor {
pub options: MemoryEditorOptions,
/* private fields */
}Expand description
The main struct for the editor window. This should persist between frames as it keeps track of quite a bit of state.
Fields§
§options: MemoryEditorOptionsA collection of options relevant for the MemoryEditor window.
Can optionally be serialized/deserialized with serde
Implementations§
Source§impl MemoryEditor
impl MemoryEditor
Sourcepub fn new() -> Self
pub fn new() -> Self
Create the MemoryEditor, which should be kept in memory between frames.
The read_function should return one u8 value from the object which you provide in
either the Self::window_ui or the Self::draw_editor_contents method.
let mut memory_base = vec![0xFF; 0xFF];
let mut is_open = true;
let mut memory_editor = MemoryEditor::new().with_address_range("Memory", 0..0xFF);
// Show a read-only window
memory_editor.window_ui_read_only(&ctx, &mut is_open, &mut memory_base, |mem, addr| mem[addr].into());Sourcepub fn visible_range(&self) -> &Range<Address>
pub fn visible_range(&self) -> &Range<Address>
Returns the visible range of the last frame.
Can be useful for asynchronous memory querying.
Sourcepub fn window_ui_read_only<T: ?Sized>(
&mut self,
ctx: &Context,
is_open: &mut bool,
mem: &mut T,
read_fn: impl FnMut(&mut T, Address) -> Option<u8>,
)
pub fn window_ui_read_only<T: ?Sized>( &mut self, ctx: &Context, is_open: &mut bool, mem: &mut T, read_fn: impl FnMut(&mut T, Address) -> Option<u8>, )
Create a read-only window and render the memory editor contents within.
If you want to make your own window/container to be used for the editor contents, you can use Self::draw_editor_contents.
If you wish to be able to write to the memory, you can use Self::window_ui.
§Arguments
ctx- Theeguicontext.mem- The memory from which to read.read_fn- Any closure which takes in a reference to the memory and an address and returns au8value. It can returnNoneif the data at the specified address is not available for whatever reason. This will then be rendered as--(SeeMemoryEditorOptions::none_display_value)
Sourcepub fn window_ui<T: ?Sized>(
&mut self,
ctx: &Context,
is_open: &mut bool,
mem: &mut T,
read_fn: impl FnMut(&mut T, Address) -> Option<u8>,
write_fn: impl FnMut(&mut T, Address, u8),
)
pub fn window_ui<T: ?Sized>( &mut self, ctx: &Context, is_open: &mut bool, mem: &mut T, read_fn: impl FnMut(&mut T, Address) -> Option<u8>, write_fn: impl FnMut(&mut T, Address, u8), )
Create a window and render the memory editor contents within.
If you want to make your own window/container to be used for the editor contents, you can use Self::draw_editor_contents.
If you wish for read-only access to the memory, you can use Self::window_ui_read_only.
§Arguments
ctx- Theeguicontext.mem- The memory from which to read.read_fn- Any closure which takes in a reference to the memory and an address and returns au8value. It can returnNoneif the data at the specified address is not available for whatever reason. This will then be rendered as--(SeeMemoryEditorOptions::none_display_value)write_fn- Any closure which can take a reference to the memory, an address, and the value to write.
Sourcepub fn draw_editor_contents_read_only<T: ?Sized>(
&mut self,
ui: &mut Ui,
mem: &mut T,
read_fn: impl FnMut(&mut T, Address) -> Option<u8>,
)
pub fn draw_editor_contents_read_only<T: ?Sized>( &mut self, ui: &mut Ui, mem: &mut T, read_fn: impl FnMut(&mut T, Address) -> Option<u8>, )
Draws the actual memory viewer/editor.
Can be included in whatever container you want.
Use Self::window_ui if you want to have a window with the contents instead.
This is the read-only variant. See Self::draw_editor_contents for the read-write variant.
Sourcepub fn draw_editor_contents<T: ?Sized>(
&mut self,
ui: &mut Ui,
mem: &mut T,
read_fn: impl FnMut(&mut T, Address) -> Option<u8>,
write_fn: impl FnMut(&mut T, Address, u8),
)
pub fn draw_editor_contents<T: ?Sized>( &mut self, ui: &mut Ui, mem: &mut T, read_fn: impl FnMut(&mut T, Address) -> Option<u8>, write_fn: impl FnMut(&mut T, Address, u8), )
Draws the actual memory viewer/editor.
Can be included in whatever container you want.
Use Self::window_ui if you want to have a window with the contents instead.
If the read-only variant is preferred see Self::draw_editor_contents_read_only.
Sourcepub fn with_window_title(self, title: impl Into<String>) -> Self
pub fn with_window_title(self, title: impl Into<String>) -> Self
Set the window title, only relevant if using the window_ui() call.
Sourcepub fn with_address_range(
self,
range_name: impl Into<String>,
address_range: Range<Address>,
) -> Self
pub fn with_address_range( self, range_name: impl Into<String>, address_range: Range<Address>, ) -> Self
Add an address range to the range list. Multiple address ranges can be added, and will be displayed in the UI by a drop-down box if more than one range was added.
The first range that is added will be displayed by default when launching the UI.
The UI will query your set read_function with the values within this Range
Sourcepub fn set_address_range(
&mut self,
range_name: impl Into<String>,
address_range: Range<Address>,
)
pub fn set_address_range( &mut self, range_name: impl Into<String>, address_range: Range<Address>, )
Add or update an address range.
See also Self::with_address_range
Sourcepub fn with_options(self, options: MemoryEditorOptions) -> Self
pub fn with_options(self, options: MemoryEditorOptions) -> Self
Set the memory options, useful if you use the persistence feature.
Sourcepub fn set_options(&mut self, options: MemoryEditorOptions)
pub fn set_options(&mut self, options: MemoryEditorOptions)
Set the memory options, useful if you use the persistence feature.
See also Self::with_options
Trait Implementations§
Source§impl Clone for MemoryEditor
impl Clone for MemoryEditor
Source§fn clone(&self) -> MemoryEditor
fn clone(&self) -> MemoryEditor
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MemoryEditor
impl RefUnwindSafe for MemoryEditor
impl Send for MemoryEditor
impl Sync for MemoryEditor
impl Unpin for MemoryEditor
impl UnwindSafe for MemoryEditor
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)