Struct gltf_json::root::Root

source ·
pub struct Root {
Show 19 fields pub accessors: Vec<Accessor>, pub animations: Vec<Animation>, pub asset: Asset, pub buffers: Vec<Buffer>, pub buffer_views: Vec<View>, pub scene: Option<Index<Scene>>, pub extensions: Option<Root>, pub extras: Extras, pub extensions_used: Vec<String>, pub extensions_required: Vec<String>, pub cameras: Vec<Camera>, pub images: Vec<Image>, pub materials: Vec<Material>, pub meshes: Vec<Mesh>, pub nodes: Vec<Node>, pub samplers: Vec<Sampler>, pub scenes: Vec<Scene>, pub skins: Vec<Skin>, pub textures: Vec<Texture>,
}
Expand description

The root object of a glTF 2.0 asset.

Fields§

§accessors: Vec<Accessor>

An array of accessors.

§animations: Vec<Animation>

An array of keyframe animations.

§asset: Asset

Metadata about the glTF asset.

§buffers: Vec<Buffer>

An array of buffers.

§buffer_views: Vec<View>

An array of buffer views.

§scene: Option<Index<Scene>>

The default scene.

§extensions: Option<Root>

Extension specific data.

§extras: Extras

Optional application specific data.

§extensions_used: Vec<String>

Names of glTF extensions used somewhere in this asset.

§extensions_required: Vec<String>

Names of glTF extensions required to properly load this asset.

§cameras: Vec<Camera>

An array of cameras.

§images: Vec<Image>

An array of images.

§materials: Vec<Material>

An array of materials.

§meshes: Vec<Mesh>

An array of meshes.

§nodes: Vec<Node>

An array of nodes.

§samplers: Vec<Sampler>

An array of samplers.

§scenes: Vec<Scene>

An array of scenes.

§skins: Vec<Skin>

An array of skins.

§textures: Vec<Texture>

An array of textures.

Implementations§

source§

impl Root

source

pub fn get<T>(&self, index: Index<T>) -> Option<&T>
where Self: Get<T>,

Returns a single item from the root object.

source

pub fn push<T>(&mut self, value: T) -> Index<T>
where Self: AsMut<Vec<T>>,

Insert the given value into this (as via Vec::push()), then return the Index to it.

This allows you to easily obtain Index values with the correct index and type when creating a glTF asset.

If you have a mutable borrow conflict when using this method, consider using the more explicit Index::push() method, passing it only the necessary vector.

§Panics

Panics if there are already u32::MAX or more elements of this type, in which case an Index cannot be created.

source

pub fn from_str(str_: &str) -> Result<Self, Error>

Deserialize from a JSON string slice.

source

pub fn from_slice(slice: &[u8]) -> Result<Self, Error>

Deserialize from a JSON byte slice.

source

pub fn from_reader<R>(reader: R) -> Result<Self, Error>
where R: Read,

Deserialize from a stream of JSON.

source

pub fn to_string(&self) -> Result<String, Error>

Serialize as a String of JSON.

source

pub fn to_string_pretty(&self) -> Result<String, Error>

Serialize as a pretty-printed String of JSON.

source

pub fn to_value(&self) -> Result<Value, Error>

Serialize as a generic JSON value.

source

pub fn to_vec(&self) -> Result<Vec<u8>, Error>

Serialize as a JSON byte vector.

source

pub fn to_vec_pretty(&self) -> Result<Vec<u8>, Error>

Serialize as a pretty-printed JSON byte vector.

source

pub fn to_writer<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Serialize as a JSON byte writertor.

source

pub fn to_writer_pretty<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Serialize as a pretty-printed JSON byte writertor.

Trait Implementations§

source§

impl AsMut<Vec<Accessor>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Accessor>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Animation>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Animation>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Buffer>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Buffer>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Camera>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Camera>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Image>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Image>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Material>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Material>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Mesh>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Mesh>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Node>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Node>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Sampler>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Sampler>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Scene>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Scene>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Skin>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Skin>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<Texture>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<Texture>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<Vec<View>> for Root

source§

fn as_mut(&mut self) -> &mut Vec<View>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<[Accessor]> for Root

source§

fn as_ref(&self) -> &[Accessor]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Animation]> for Root

source§

fn as_ref(&self) -> &[Animation]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Buffer]> for Root

source§

fn as_ref(&self) -> &[Buffer]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Camera]> for Root

source§

fn as_ref(&self) -> &[Camera]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Image]> for Root

source§

fn as_ref(&self) -> &[Image]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Material]> for Root

source§

fn as_ref(&self) -> &[Material]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Mesh]> for Root

source§

fn as_ref(&self) -> &[Mesh]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Node]> for Root

source§

fn as_ref(&self) -> &[Node]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Sampler]> for Root

source§

fn as_ref(&self) -> &[Sampler]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Scene]> for Root

source§

fn as_ref(&self) -> &[Scene]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Skin]> for Root

source§

fn as_ref(&self) -> &[Skin]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[Texture]> for Root

source§

fn as_ref(&self) -> &[Texture]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<[View]> for Root

source§

fn as_ref(&self) -> &[View]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Root

source§

fn clone(&self) -> Root

Returns a copy 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 Root

source§

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

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

impl Default for Root

source§

fn default() -> Root

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Root

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<'a> Get<Accessor> for Root

source§

fn get(&self, index: Index<Accessor>) -> Option<&Accessor>

Retrieves a single value at the given index.
source§

impl<'a> Get<Animation> for Root

source§

fn get(&self, index: Index<Animation>) -> Option<&Animation>

Retrieves a single value at the given index.
source§

impl<'a> Get<Buffer> for Root

source§

fn get(&self, index: Index<Buffer>) -> Option<&Buffer>

Retrieves a single value at the given index.
source§

impl<'a> Get<Camera> for Root

source§

fn get(&self, index: Index<Camera>) -> Option<&Camera>

Retrieves a single value at the given index.
source§

impl<'a> Get<Image> for Root

source§

fn get(&self, index: Index<Image>) -> Option<&Image>

Retrieves a single value at the given index.
source§

impl<'a> Get<Material> for Root

source§

fn get(&self, index: Index<Material>) -> Option<&Material>

Retrieves a single value at the given index.
source§

impl<'a> Get<Mesh> for Root

source§

fn get(&self, index: Index<Mesh>) -> Option<&Mesh>

Retrieves a single value at the given index.
source§

impl<'a> Get<Node> for Root

source§

fn get(&self, index: Index<Node>) -> Option<&Node>

Retrieves a single value at the given index.
source§

impl<'a> Get<Sampler> for Root

source§

fn get(&self, index: Index<Sampler>) -> Option<&Sampler>

Retrieves a single value at the given index.
source§

impl<'a> Get<Scene> for Root

source§

fn get(&self, index: Index<Scene>) -> Option<&Scene>

Retrieves a single value at the given index.
source§

impl<'a> Get<Skin> for Root

source§

fn get(&self, index: Index<Skin>) -> Option<&Skin>

Retrieves a single value at the given index.
source§

impl<'a> Get<Texture> for Root

source§

fn get(&self, index: Index<Texture>) -> Option<&Texture>

Retrieves a single value at the given index.
source§

impl<'a> Get<View> for Root

source§

fn get(&self, index: Index<View>) -> Option<&View>

Retrieves a single value at the given index.
source§

impl Serialize for Root

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
source§

impl Validate for Root

source§

fn validate<P, R>(&self, _root: &Root, _path: P, _report: &mut R)
where P: Fn() -> Path, R: FnMut(&dyn Fn() -> Path, Error),

Validates the invariants required for the library to function safely.

Auto Trait Implementations§

§

impl Freeze for Root

§

impl RefUnwindSafe for Root

§

impl Send for Root

§

impl Sync for Root

§

impl Unpin for Root

§

impl UnwindSafe for Root

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

§

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

§

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

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,