pub struct Document {
pub engine: EngineState,
/* private fields */
}Expand description
ONE open model: the engine that owns it plus the identity the file lane needs — the store name it was opened from / saved to, and the clean baseline.
Fields§
§engine: EngineStateThe windowing-agnostic brain for THIS document (scene, camera, history, settings, selection). Panels borrow it; it is never forked.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(engine: EngineState) -> Self
pub fn new(engine: EngineState) -> Self
Wrap engine as a document, taking its CURRENT model as the clean
baseline — so a freshly loaded (or freshly emptied) document is clean and
the first edit marks it dirty.
Sourcepub fn recovered(engine: EngineState, name: Option<String>) -> Self
pub fn recovered(engine: EngineState, name: Option<String>) -> Self
Wrap engine as a document RESTORED from the autosave blob
(crate::recovery): it carries the store identity it had (None for
an untitled one) and NO clean baseline, so it is dirty from its first
frame — the work it holds is exactly what was never saved, and the close
guard and the tab dot must say so until a Save writes it somewhere.
pub fn set_name(&mut self, name: Option<String>)
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Snapshot the current model as the clean baseline (after New / Open /
Save, or a ?loadModel= boot-load).
Sourcepub fn is_dirty(&self) -> bool
pub fn is_dirty(&self) -> bool
Dirty = the live model differs from the last saved/opened baseline. (Rolling the history does NOT change the request document, so navigating steps never marks dirty — only real edits/add/delete/reorder do.)
HONEST but not free: it serializes the whole request document, which for
an assembly carrying an embedded parts library is megabytes. Every place
where being wrong would cost the user work — the close prompt, Save —
calls THIS. The per-frame tab dot calls Self::dirty_marker instead.
Sourcepub fn refresh_dirty_marker(&mut self)
pub fn refresh_dirty_marker(&mut self)
The cached dirty flag the tab strip draws, recomputed only when the
document’s APPLIED RUN generation moved. Every ordinary edit (a param
change, add, delete, reorder, undo) re-runs the history and bumps that
generation, so the dot tracks editing; a mutation that changes the
document WITHOUT a re-run (an object-metadata write) can leave the dot
one edit behind. That is a marker being briefly optimistic, never a lost
edit: Self::is_dirty is recomputed honestly at the close prompt.
The alternative — serializing every open document every frame — is a per-frame multi-megabyte cost per tab, and the app pays no such cost today.
pub fn dirty_marker(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for Document
impl !Send for Document
impl !Sync for Document
impl !UnwindSafe for Document
impl Freeze for Document
impl Unpin for Document
impl UnsafeUnpin for Document
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more