[][src]Struct blend::runtime::Instance

pub struct Instance<'a> {
    pub type_name: String,
    pub data: InstanceDataFormat<'a>,
    pub fields: LinkedHashMap<String, FieldTemplate>,
    // some fields omitted
}

Represents a block of data inside the blend file. An Instance can be a camera, a mesh, a material, or anything else Blender uses internally, like material nodes, user settings or render options. An Instance is conceptually a struct: a collection of named fields which can themselves be structs or primitives.

Fields

type_name: Stringdata: InstanceDataFormat<'a>

The raw binary data this Instance owns.

fields: LinkedHashMap<String, FieldTemplate>

The fields of this Instance.

Methods

impl<'a> Instance<'a>[src]

pub fn code(&self) -> [u8; 4][src]

If this Instance was created from a primary/root Block it will have a code. Possible codes include "OB" for objects, "ME" for meshes, "CA" for cameras, etc.

Panics

Panics if the instance's underlying data doesn't have a code

pub fn memory_address(&self) -> NonZeroU64[src]

If this Instance was created from a primary/root or subsidiary Block it will have a memory address. Blender dumps its memory into the blend file when saving and the old memory addresses are used the recreate the connections between blocks when loading the file again.

Panics

Panics if the instance underlying data doesn't have an old memory address.

pub fn is_valid<T: AsRef<str>>(&self, name: T) -> bool[src]

Tests whether a field is valid and can be accessed using the get methods without panicking. Which get method you have to use depends on the field type.

pub fn get_u8<T: AsRef<str>>(&self, name: T) -> u8[src]

pub fn get_i8<T: AsRef<str>>(&self, name: T) -> i8[src]

pub fn get_char<T: AsRef<str>>(&self, name: T) -> char[src]

pub fn get_u16<T: AsRef<str>>(&self, name: T) -> u16[src]

pub fn get_i16<T: AsRef<str>>(&self, name: T) -> i16[src]

pub fn get_i32<T: AsRef<str>>(&self, name: T) -> i32[src]

pub fn get_f32<T: AsRef<str>>(&self, name: T) -> f32[src]

pub fn get_f64<T: AsRef<str>>(&self, name: T) -> f64[src]

pub fn get_u64<T: AsRef<str>>(&self, name: T) -> u64[src]

pub fn get_i64<T: AsRef<str>>(&self, name: T) -> i64[src]

pub fn get_u8_vec<T: AsRef<str>>(&self, name: T) -> Vec<u8>[src]

pub fn get_i8_vec<T: AsRef<str>>(&self, name: T) -> Vec<i8>[src]

pub fn get_i32_vec<T: AsRef<str>>(&self, name: T) -> Vec<i32>[src]

pub fn get_i16_vec<T: AsRef<str>>(&self, name: T) -> Vec<i16>[src]

pub fn get_f32_vec<T: AsRef<str>>(&self, name: T) -> Vec<f32>[src]

pub fn get_f64_vec<T: AsRef<str>>(&self, name: T) -> Vec<f64>[src]

pub fn get_u64_vec<T: AsRef<str>>(&self, name: T) -> Vec<u64>[src]

pub fn get_i64_vec<T: AsRef<str>>(&self, name: T) -> Vec<i64>[src]

pub fn get_string<T: AsRef<str>>(&self, name: T) -> String[src]

Example

let obj = blend.get_by_code(*b"OB").next().unwrap();
let name = obj.get("id").get_string("name");

Panics

  • Panics if the field cannot be read as a string.

pub fn get<T: AsRef<str>>(&self, name: T) -> Instance<'a>[src]

Used to access fields which are structs.

Example

let obj = blend.get_by_code(*b"OB").next().unwrap();
let id = obj.get("id");
let data = obj.get("data");

Panics

  • Panics if the field is not a valid struct.

pub fn get_iter<T: AsRef<str>>(
    &self,
    name: T
) -> impl Iterator<Item = Instance<'a>>
[src]

Used to access fields which are lists of structs.

Example

let obj = blend.get_by_code(*b"OB").next().unwrap();
let materials = obj.get_iter("mat").collect::<Vec<_>>();

Panics

  • Panics if the field is not a valid list of structs.

Trait Implementations

impl<'a> Clone for Instance<'a>[src]

impl<'a> Debug for Instance<'a>[src]

impl<'_> Display for Instance<'_>[src]

Auto Trait Implementations

impl<'a> Send for Instance<'a>

impl<'a> Unpin for Instance<'a>

impl<'a> Sync for Instance<'a>

impl<'a> UnwindSafe for Instance<'a>

impl<'a> RefUnwindSafe for Instance<'a>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]