Skip to main content

Instructions

Struct Instructions 

Source
pub struct Instructions {
    pub schema: u32,
    pub target: Target,
    pub template: Template,
    pub front: FrontMatter,
    pub steps: Vec<Step>,
    pub id_counter: u64,
    pub retarget: Option<Retarget>,
}

Fields§

§schema: u32§target: Target

The assembly revision these instructions describe. Authoritative: the server derives what the instructions reference from this field alone.

§template: Template§front: FrontMatter§steps: Vec<Step>

The top-level steps, in order; each may hold children (Step::steps).

§id_counter: u64§retarget: Option<Retarget>

A re-target waiting for the author’s approval. Release is refused while it is set.

Implementations§

Source§

impl Instructions

Source

pub fn new(target: Target) -> Self

A new, empty block for target.

Source

pub fn from_value(value: &Value) -> Result<Self, String>

Read the block from its JSON, validated. A schema-1 block (chapters of steps) reads as the tree: the root chapter’s steps at the top, a sub-assembly’s chapter as the children of the step that places it, and is schema 2 from then on (written back on the next edit).

Source

pub fn coalesce_adds(&mut self)

Every step’s adds as one row per part (Step::coalesce_adds).

Source

pub fn from_document(document: &Value) -> Result<Option<Self>, String>

Read the block out of a whole document, if it has one.

Source

pub fn to_value(&self) -> Value

Source

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

The structural rules: a known schema, a template the layout can draw, unique step and field ids over the whole tree, well-formed fields, and no occurrence added twice.

Source

pub fn next_id(&mut self, prefix: &str) -> String

A fresh id with prefix (MS step, MK callout, MF field; MC was a chapter).

Source

pub fn step_count(&self) -> usize

Source

pub fn steps(&self) -> impl Iterator<Item = (usize, &Step)>

Every step in reading order (a step’s children, depth first, before the step itself) with its depth (0 at the top).

Source

pub fn step(&self, step_id: &str) -> Option<&Step>

Source

pub fn step_mut(&mut self, step_id: &str) -> Option<&mut Step>

Source

pub fn siblings(&self, step_id: &str) -> Option<(&[Step], usize)>

The list the step sits in (its siblings, itself included) and its index there.

Source

pub fn siblings_mut(&mut self, step_id: &str) -> Option<(&mut Vec<Step>, usize)>

Source

pub fn parent_id(&self, step_id: &str) -> Option<Option<&str>>

The parent step’s id: Some(None) at the top level, None for an unknown step.

Source

pub fn depth(&self, step_id: &str) -> Option<usize>

How deep a step sits: 0 at the top level.

Source

pub fn group_steps_mut(&mut self, occurrence: &str) -> Option<&mut Vec<Step>>

The steps that build one assembly: the top level for "", else the children of the step that places the sub-assembly at occurrence.

Source

pub fn step_number(&self, step_id: &str) -> Option<usize>

The step number a reader sees (1-based, in reading order).

Source

pub fn tools_list(&self) -> Vec<(ToolUse, Vec<String>)>

Distinct tools in first-use order, with the step ids that use each.

Source

pub fn parts_list(&self) -> Vec<PartsRow>

The parts list: one row per part (and per sub-assembly), with its find number and the quantity added over every step, in first-add order.

Trait Implementations§

Source§

impl Clone for Instructions

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 Instructions

Source§

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

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

impl<'de> Deserialize<'de> for Instructions

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 Instructions

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 Instructions

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 Instructions

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.