TreadlingInfo

Struct TreadlingInfo 

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

The treadling or lift plan for a draft, also includes the tie-up and whether the loom is rising or sinking shed

Implementations§

Source§

impl TreadlingInfo

Source

pub fn new(shaft_count: u32, tie_up: TieUpCreate, rise_sink: RiseSink) -> Self

Construct new treadling

§Panics

If shaft or treadle count is 0

Source

pub fn shaft_count(&self) -> u32

Get the shaft count

Source

pub fn max_shaft_used(&self) -> u32

Returns max shaft used. If this is a direct tie-up, it’s the max shaft in the lift plan. If it’s an indirect tie-up, it’s the max shaft used in the tie-up, even if no picks use a treadle tied to that shaft

Source

pub fn set_shaft_count(&mut self, shaft_count: u32) -> Result<(), u32>

Non-destructively sets shaft count

§Errors

If shaft_count is less than the max shaft used, returns max shaft

Source

pub fn tie_up(&self) -> &TieUpKind

Get the tie-up info

Source

pub fn treadle_count(&self) -> u32

Get the treadle count. Returns the shaft count if directly tied up

Source

pub fn rise_sink(&self) -> RiseSink

Whether the treadling is for a rising shaft or sinking shaft loom

Source

pub fn len(&self) -> usize

Number of picks in the treadling

Source

pub fn is_empty(&self) -> bool

Is the treadling empty

Source

pub fn push_single(&mut self, treadle: u32) -> Result<(), u32>

Add a new pick at the end using just the given treadle

§Errors

If treadle is higher than number of shafts, returns treadle

Source

pub fn push(&mut self, treadles: HashSet<u32>) -> Result<(), u32>

Add a new pick at the end using all given treadles/shafts

§Errors

If any treadle is over the number of treadles/shafts, returns that value

Source

pub fn toggle_treadle( &mut self, index: usize, treadle: Treadle, ) -> Result<bool, u32>

Toggle treadle at given index. Return true if treadle has been toggled on, false if toggled off

§Errors

If treadle is invalid

§Panics

If index is out of bounds

Source

pub fn insert( &mut self, index: usize, treadles: HashSet<u32>, ) -> Result<(), u32>

Inserts treadling at given index

§Errors

If any treadles are invalid

§Panics

If index is out of bounds

Source

pub fn splice<R>( &mut self, range: R, replace_with: Vec<HashSet<u32>>, ) -> Result<Vec<HashSet<u32>>, u32>
where R: RangeBounds<usize>,

Based on Vec::splice, it splices the given sequence into the given range. It validates that the elements in replace_with are inside the shaft bounds, and it returns the replaced elements.

§Errors

If an element in replace_with is larger than the shaft count, returns index of first out-of-bounds element

Source

pub fn put( &mut self, index: usize, treadles: HashSet<u32>, ) -> Result<Option<HashSet<u32>>, u32>

Overwrites the treadling at the given index with the new treadles

§Errors

If treadling is invalid

§Panics

If index is greater than the length of the treadling

Source

pub fn make_rising(&mut self)

Convert in place to a rising shaft treadling

Source

pub fn make_sinking(&mut self)

Convert in place to a sinking shaft treadling

Source

pub fn make_lift_plan(&mut self) -> bool

Goes from a treadling to a lift plan. Returns false if already a lift plan, true if conversion happened

Source

pub fn invert(&mut self)

Switch from rising to sinking or vice versa

Trait Implementations§

Source§

impl Clone for TreadlingInfo

Source§

fn clone(&self) -> TreadlingInfo

Returns a duplicate 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 TreadlingInfo

Source§

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

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

impl Default for TreadlingInfo

Source§

fn default() -> Self

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

impl Index<usize> for TreadlingInfo

Source§

type Output = HashSet<u32>

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for TreadlingInfo

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TreadlingInfo

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> 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 = 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.