UnityDocument

Trait UnityDocument 

Source
pub trait UnityDocument {
Show 15 methods // Required methods fn entry(&self) -> Option<&UnityClass>; fn entry_mut(&mut self) -> Option<&mut UnityClass>; fn entries(&self) -> &[UnityClass]; fn entries_mut(&mut self) -> &mut Vec<UnityClass>; fn add_entry(&mut self, entry: UnityClass); fn file_path(&self) -> Option<&Path>; fn save(&self) -> Result<(), UnityAssetError>; fn save_to<P>(&self, path: P) -> Result<(), UnityAssetError> where P: AsRef<Path>; fn format(&self) -> DocumentFormat; // Provided methods fn filter_by_class(&self, class_name: &str) -> Vec<&UnityClass> { ... } fn filter_by_classes(&self, class_names: &[&str]) -> Vec<&UnityClass> { ... } fn filter<F>(&self, predicate: F) -> Vec<&UnityClass> where F: Fn(&UnityClass) -> bool { ... } fn find_by_class_and_property( &self, class_name: &str, property: &str, ) -> Option<&UnityClass> { ... } fn is_empty(&self) -> bool { ... } fn len(&self) -> usize { ... }
}
Expand description

Abstract trait for Unity documents

Required Methods§

Source

fn entry(&self) -> Option<&UnityClass>

Get the first entry (main object) in the document

Source

fn entry_mut(&mut self) -> Option<&mut UnityClass>

Get a mutable reference to the first entry

Source

fn entries(&self) -> &[UnityClass]

Get all entries in the document

Source

fn entries_mut(&mut self) -> &mut Vec<UnityClass>

Get mutable access to all entries

Source

fn add_entry(&mut self, entry: UnityClass)

Add a new Unity object to the document

Source

fn file_path(&self) -> Option<&Path>

Get the file path this document was loaded from

Source

fn save(&self) -> Result<(), UnityAssetError>

Save the document back to its original file

Source

fn save_to<P>(&self, path: P) -> Result<(), UnityAssetError>
where P: AsRef<Path>,

Save the document to a specific file

Source

fn format(&self) -> DocumentFormat

Get the document format

Provided Methods§

Source

fn filter_by_class(&self, class_name: &str) -> Vec<&UnityClass>

Filter entries by class name

Source

fn filter_by_classes(&self, class_names: &[&str]) -> Vec<&UnityClass>

Filter entries by multiple class names

Source

fn filter<F>(&self, predicate: F) -> Vec<&UnityClass>
where F: Fn(&UnityClass) -> bool,

Filter entries by a custom predicate

Source

fn find_by_class_and_property( &self, class_name: &str, property: &str, ) -> Option<&UnityClass>

Find a single entry by class name and optional property filter

Source

fn is_empty(&self) -> bool

Check if the document is empty

Source

fn len(&self) -> usize

Get the number of entries in the document

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§