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

source

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());
source

pub fn visible_range(&self) -> &Range<Address>

Returns the visible range of the last frame.

Can be useful for asynchronous memory querying.

source

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 - The egui 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 a u8 value. It can return None if the data at the specified address is not available for whatever reason. This will then be rendered as -- (See MemoryEditorOptions::none_display_value)
source

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 - The egui 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 a u8 value. It can return None if the data at the specified address is not available for whatever reason. This will then be rendered as -- (See MemoryEditorOptions::none_display_value)
  • write_fn - Any closure which can take a reference to the memory, an address, and the value to write.
source

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.

source

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.

source

pub fn with_window_title(self, title: impl Into<String>) -> Self

Set the window title, only relevant if using the window_ui() call.

source

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

source

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

source

pub fn with_options(self, options: MemoryEditorOptions) -> Self

Set the memory options, useful if you use the persistence feature.

source

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

source§

fn clone(&self) -> MemoryEditor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for MemoryEditor

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,