Skip to main content

Document

Struct Document 

Source
pub struct Document {
    pub format_version: u32,
    pub compositions: CompMap,
    pub nodes: NodeMap,
    pub assets: AssetMap,
    pub asset_order: Vec<AssetId>,
    pub main: CompId,
}

Fields§

§format_version: u32§compositions: CompMap§nodes: NodeMap§assets: AssetMap§asset_order: Vec<AssetId>

Live/attached assets in UI order.

§main: CompId

Implementations§

Source§

impl Document

Source

pub fn empty() -> Self

Source

pub fn create_node(&mut self, node: Node) -> NodeId

Source

pub fn attach( &mut self, id: NodeId, parent: Parent, index: usize, ) -> Result<(), ModelError>

Source

pub fn detach(&mut self, id: NodeId) -> Result<(Parent, usize), ModelError>

Source

pub fn locate(&self, id: NodeId) -> Option<(Parent, usize)>

Source

pub fn garbage_collect(&mut self)

Drop arena nodes not reachable from any composition (call before save).

Source

pub fn normalize_assets(&mut self)

Rebuild asset_order to match the arena: every attached id must exist and be unique. Any arena asset missing from the order gets appended. (Call after loading legacy projects that predate asset_order.)

Source

pub fn image_asset(&self, id: AssetId) -> Option<&ImageAsset>

The embedded image asset behind id, if it is an image.

Source

pub fn image_usage_count(&self, asset: AssetId) -> usize

Number of image-layer nodes referencing asset.

Source

pub fn font_asset_for_family( &self, family: &str, ) -> Option<(AssetId, &FontAsset)>

The font asset whose family matches family, if the project has one. Surfaces the AssetId (for removal) alongside the asset.

Source

pub fn font_families(&self) -> Vec<String>

Sorted, deduplicated family keys of every font asset in the project.

Source§

impl Document

Source

pub fn find_nodes_by_name<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = NodeId> + 'a

All live node ids whose name equals name. Lets hosts (games) find nodes by name without tracking NodeIds across document loads.

Source

pub fn set_static( &mut self, id: NodeId, prop: &PropPath, v: &Value, ) -> Result<Value, ModelError>

Set the base value; returns previous base (for undo).

Source

pub fn add_keyframe( &mut self, id: NodeId, prop: &PropPath, frame: Frame, v: &Value, ) -> Result<Option<KeyframeData>, ModelError>

Insert/update key at frame; returns replaced key if any (for undo).

Source

pub fn remove_keyframe( &mut self, id: NodeId, prop: &PropPath, frame: Frame, ) -> Result<KeyframeData, ModelError>

Source

pub fn restore_keyframe( &mut self, id: NodeId, prop: &PropPath, key: &KeyframeData, ) -> Result<(), ModelError>

Source

pub fn move_keyframe( &mut self, id: NodeId, prop: &PropPath, from: Frame, to: Frame, ) -> Result<(), ModelError>

Source

pub fn set_easing( &mut self, id: NodeId, prop: &PropPath, frame: Frame, i: Interpolation, o: EasingHandle, e: EasingHandle, ) -> Result<(Interpolation, EasingHandle, EasingHandle), ModelError>

Returns previous easing (for undo).

Source

pub fn property_is_animated(&self, id: NodeId, prop: &PropPath) -> bool

Source

pub fn value_at( &self, id: NodeId, prop: &PropPath, frame: f64, ) -> Result<Value, ModelError>

Source

pub fn get_static( &self, id: NodeId, prop: &PropPath, ) -> Result<Value, ModelError>

Source

pub fn keyframe_data( &self, id: NodeId, prop: &PropPath, frame: Frame, ) -> Option<KeyframeData>

Source

pub fn key_frames(&self, id: NodeId, prop: &PropPath) -> Vec<Frame>

All keyframe frames on a property, sorted (empty if missing).

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for Document

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Document

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.