Skip to main content

EditorModel

Struct EditorModel 

Source
pub struct EditorModel {
    pub recipe_name: String,
    pub recipe_description: String,
    pub nodes: Vec<EditorNode>,
    pub selected_index: Option<usize>,
    pub dirty: bool,
    pub undo_stack: Vec<EditorSnapshot>,
    pub redo_stack: Vec<EditorSnapshot>,
    pub source: EditorSource,
}
Expand description

The main editor state. Pure data — all mutations are method calls that modify fields in place. No I/O, no side effects.

Fields§

§recipe_name: String§recipe_description: String§nodes: Vec<EditorNode>§selected_index: Option<usize>§dirty: bool§undo_stack: Vec<EditorSnapshot>§redo_stack: Vec<EditorSnapshot>§source: EditorSource

Implementations§

Source§

impl EditorModel

Source

pub fn from_definition(def: &Definition, source: EditorSource) -> Self

Build an editor model from a parsed Definition.

Source

pub fn to_definition(&self) -> Definition

Serialize the editor state back to a Definition.

Source§

impl EditorModel

Source

pub fn load(path: &Path) -> Result<Self, EditorError>

Load a recipe from a .bnto.json file.

Source

pub fn save_to(&self, path: &Path) -> Result<(), EditorError>

Save the current editor state to a .bnto.json file. Uses atomic write (write to temp, then rename) to prevent corruption.

Source

pub fn save_path(&self, recipes_dir: &Path) -> PathBuf

Resolve the save destination path based on the recipe’s source.

  • File(path) → save back to that path
  • New or Predefined → save to recipes_dir/{slug}.bnto.json
Source§

impl EditorModel

Source

pub fn add_node(&mut self, node_type: &str, info: &NodeTypeInfo)

Add a node with defaults populated from engine metadata.

Source

pub fn add_node_with_defaults( &mut self, node_type: &str, info: &NodeTypeInfo, param_defaults: &[(String, Value)], )

Add a node with pre-populated default parameter values from metadata.

Source

pub fn remove_node(&mut self, index: usize)

Remove the node at the given index.

Source

pub fn reorder(&mut self, from: usize, to: usize)

Swap nodes at positions from and to.

Source

pub fn update_param(&mut self, index: usize, key: &str, value: Value)

Update a single parameter value on the node at index.

Source

pub fn undo(&mut self)

Undo the last mutation.

Source

pub fn redo(&mut self)

Redo the last undone mutation.

Source

pub fn mark_clean(&mut self)

Mark the model as clean (after a successful save).

Source§

impl EditorModel

Source

pub fn new() -> Self

Create a blank editor with no nodes.

Trait Implementations§

Source§

impl Clone for EditorModel

Source§

fn clone(&self) -> EditorModel

Returns a duplicate 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 Debug for EditorModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EditorModel

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.