Skip to main content

PlayerData

Struct PlayerData 

Source
pub struct PlayerData {
Show 13 fields pub schema: u32, pub title: String, pub subtitle: String, pub target: Target, pub steps: Vec<PlayerStep>, pub tools: Vec<ToolUse>, pub tool_pictures: BTreeMap<String, String>, pub meshes: Vec<PlayerMesh>, pub nodes: Vec<PlayerNode>, pub assembly: Vec<PlayerComponent>, pub motion: Option<Motion>, pub style: Style, pub record_key: String,
}

Fields§

§schema: u32§title: String§subtitle: String§target: Target§steps: Vec<PlayerStep>

Every step in reading order (a step’s children before it).

§tools: Vec<ToolUse>

Distinct tools, in first-use order.

§tool_pictures: BTreeMap<String, String>

A picture per tool of the library (by toolId): the server’s own /api/tools/<id>/picture as built, which the page the PLM serves loads same-site; the offline page carries only data:image pictures (PlayerData::inline_tool_pictures), the rest dropped.

§meshes: Vec<PlayerMesh>§nodes: Vec<PlayerNode>§assembly: Vec<PlayerComponent>

The assembly’s occurrence tree, depth first (a component before its children): the Model tab’s tree and the Parts tab’s cards. Absent from data made before the tree was carried, and from a motion study’s.

§motion: Option<Motion>

A motion study’s baked frames: with no chapters the page is the study’s player (a timeline over the frames); a step may carry one too (its motion). Absent from instructions made before motion existed.

§style: Style

How the page draws the steps: the document’s style. Data made before styles existed reads as Shaded, as it was drawn; a motion study is Shaded.

§record_key: String

What an offline page keys a build’s record by in the browser’s storage (record_key): the instructions’ content, so two documents, or two revisions of one, never share values. Absent from data made before the record was kept, and from a motion study’s.

Implementations§

Source§

impl PlayerData

Source

pub fn build(block: &Instructions, scene: Scene) -> Result<Self, String>

The player data of block over scene.

Source

pub fn inline_tool_pictures( &mut self, fetched: &BTreeMap<String, Option<(String, Vec<u8>)>>, ) -> usize

Put the fetched tool pictures in: for each tool with a picture entry, fetched[id] as Some((media type, bytes)) becomes a data:image URL when the type is one the page shows (PNG, JPEG, WebP) and the bytes are within TOOL_PICTURE_MAX_BYTES; any other entry (not fetched, no picture, another type, too large) is dropped, so an offline page never carries a picture it cannot load. Returns how many were put in.

Source

pub fn motion_study( title: &str, subtitle: &str, target: Target, scene: Scene, motion: Motion, ) -> Result<Self, String>

A motion study’s player: no steps, the scene’s meshes and nodes, and the study’s frames as motion. title is the study’s name.

Source

pub fn to_json(&self) -> String

Source

pub fn from_json(text: &str) -> Result<Self, String>

Read the data, schema 1 (chapters of steps) included: its steps become one flat list, every step at the top.

Trait Implementations§

Source§

impl Clone for PlayerData

Source§

fn clone(&self) -> Self

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 Debug for PlayerData

Source§

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

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

impl<'de> Deserialize<'de> for PlayerData

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 PartialEq for PlayerData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PlayerData

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 StructuralPartialEq for PlayerData

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.