Struct SceneData

Source
pub struct SceneData { /* private fields */ }
Expand description

Owns a scene hierarchy and validated typed data. Handles belong to this generation only; retain the owner while holding handles/components.

Implementations§

Source§

impl SceneData

Source

pub fn inspect_cooked(bytes: &[u8]) -> Result<CookedMetadata, ContentError>

Inspect a cooked envelope without allocating or constructing a scene.

Checks the size, version marker, checksum, node limit and minimum space for the declared node count. Body contents (including trailing bytes), schema and hierarchy are checked only by Self::decode. Errors use zero-based binary byte offsets with line/column set to zero.

use ferravex_play::authoring::{Document, ErrorKind, SceneData, Schema};
let mut bytes = Document::load("ferravex_scene 1;", &Schema::new())?.encode()?;
assert_eq!(SceneData::inspect_cooked(&bytes)?.node_count(), 0);
let last = bytes.len() - 1;
bytes[last] ^= 1;
assert_eq!(SceneData::inspect_cooked(&bytes).unwrap_err().kind, ErrorKind::Checksum);
Source§

impl SceneData

Source

pub fn nodes(&self) -> &[DataNode]

Source

pub fn node(&self, id: &str) -> Option<&DataNode>

Source

pub fn of_kind<'a>( &'a self, kind: &'a str, ) -> impl Iterator<Item = (&'a DataNode, &'a Component)>

Source

pub fn hierarchy(&self) -> &Scene

Source

pub fn handle(&self, id: &str) -> Option<NodeId>

Source

pub fn encode(&self) -> Result<Vec<u8>, ContentError>

Source

pub fn decode(bytes: &[u8], schema: &Schema) -> Result<SceneData, ContentError>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.