pub struct ProjectHistory { /* private fields */ }Expand description
Historial de snapshots con undo/redo.
Cada acción que modifica el proyecto (añadir nota, mover fader, etc.)
debe llamar push() antes de aplicarse para poder deshacerse.
El historial mantiene un máximo de snapshots para limitar el uso de memoria.
Implementations§
Source§impl ProjectHistory
impl ProjectHistory
pub fn new(max_snapshots: usize) -> Self
pub fn with_max_bytes(self, bytes: usize) -> Self
Sourcepub fn push(
&mut self,
schema: &ProjectSchema,
label: impl Into<String>,
) -> ProjectResult<()>
pub fn push( &mut self, schema: &ProjectSchema, label: impl Into<String>, ) -> ProjectResult<()>
Guarda el estado actual antes de una acción. Llamar ANTES de modificar el proyecto.
Limpia el historial de redo (no se puede hacer redo después de una acción nueva).
Sourcepub fn undo(
&mut self,
current: &ProjectSchema,
) -> ProjectResult<Option<ProjectSchema>>
pub fn undo( &mut self, current: &ProjectSchema, ) -> ProjectResult<Option<ProjectSchema>>
Deshace la última acción. Devuelve el schema anterior y guarda el estado actual en future.
Sourcepub fn redo(
&mut self,
current: &ProjectSchema,
) -> ProjectResult<Option<ProjectSchema>>
pub fn redo( &mut self, current: &ProjectSchema, ) -> ProjectResult<Option<ProjectSchema>>
Rehace la última acción deshecha.
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn undo_label(&self) -> Option<&str>
pub fn undo_label(&self) -> Option<&str>
Descripción de la acción que se desharía.
Sourcepub fn redo_label(&self) -> Option<&str>
pub fn redo_label(&self) -> Option<&str>
Descripción de la acción que se reharía.
pub fn depth(&self) -> usize
pub fn future_depth(&self) -> usize
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Uso de memoria en bytes.
Sourcepub fn history_labels(&self) -> Vec<&str>
pub fn history_labels(&self) -> Vec<&str>
Lista de labels del historial (más reciente primero).
Auto Trait Implementations§
impl Freeze for ProjectHistory
impl RefUnwindSafe for ProjectHistory
impl Send for ProjectHistory
impl Sync for ProjectHistory
impl Unpin for ProjectHistory
impl UnsafeUnpin for ProjectHistory
impl UnwindSafe for ProjectHistory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more