Struct egui_memory_editor::MemoryEditor
source · 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: MemoryEditorOptions
A 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
- Theegui
context.mem
- The memory from which to read.read_fn
- Any closure which takes in a reference to the memory and an address and returns au8
value. It can returnNone
if 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
- Theegui
context.mem
- The memory from which to read.read_fn
- Any closure which takes in a reference to the memory and an address and returns au8
value. It can returnNone
if 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 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more