Draft

Struct Draft 

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

Structure holding all elements of a draft

Implementations§

Source§

impl Draft

Source

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

Create an empty draft with the given options

Source

pub fn threading(&self) -> &Threading

Get the threading

Source

pub fn treadling_info(&self) -> &TreadlingInfo

Get the treadling

Source

pub fn tie_up(&self) -> &TieUpKind

Get the tie-up

Source

pub fn make_rising(&mut self)

Make rising shaft

Source

pub fn make_sinking(&mut self)

Make sinking shaft

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 max_shaft(&self) -> (WeavingAxis, u32)

Max shaft used in threading or treadling

Source

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

Sets shaft count on threading and treadling. Only succeeds when non-destructive

§Errors

If shafts greater than the given count are in use, returns an error with the max used shaft and the axis it’s used on

§Panics

If shaft count is 0

Source

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

Source

pub fn push_threading(&mut self, shaft: u32) -> Result<(), u32>

Adds a new thread to teh end of the threading

§Errors

Returns the shaft if greater than shaft count

Source

pub fn insert_threading( &mut self, shaft: Shaft, index: usize, ) -> Result<(), Shaft>

Insert a thread in the threading at the given index, shifting the later threads

§Panics

If index is greater than length

§Errors

If shaft is greater than shaft_count

Source

pub fn try_insert_threading( &mut self, shaft: Shaft, index: usize, ) -> Result<Result<(), Shaft>, usize>

Insert a thread at the given index, shifting later threads

§Errors

Returns the current length if index is greater than length

Source

pub fn remove_threading(&mut self, index: usize) -> Shaft

Remove the thread at the given index, returning it as a Shaft

§Panics

If index is out of bounds

Source

pub fn get_from_threading(&self, index: usize) -> Option<&u32>

Get threading shaft at an index

Source

pub fn put_threading(&mut self, index: usize, shaft: Shaft) -> Shaft

Overwrite thread at given index, returns old thread value

§Panics

If index is out of bounds

Source

pub fn try_put_threading( &mut self, index: usize, shaft: Shaft, ) -> Result<Option<Shaft>, usize>

Overwrite thread at given index. Returns replaced shaft, or none if inserting at the end

§Errors

Returns current length if index out of bounds

Source

pub fn flip_threading_vert(&mut self)

Source

pub fn mirror_threading(&mut self)

Source

pub fn flip_threading_horiz(&mut self)

Source

pub fn push_single_treadling(&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_treadling(&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_treadle( &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_treadling<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_treadling( &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 yarn_palette(&self) -> &YarnPalette

Get yarn palette

Source

pub fn weft_yarns(&self) -> &YarnSequence

Get weft yarns

Source

pub fn warp_yarns(&self) -> &YarnSequence

Get warp yarns

Source

pub fn set_weft_yarn_repeat<T>(&mut self, yarns: T)
where T: IntoIterator<Item = Yarn>,

Set the repeat of weft yarns

Source

pub fn set_weft_yarn_offset(&mut self, offset: usize)

set weft yarn repeat offset

Source

pub fn set_weft_yarn(&mut self, index: usize, yarn: Yarn)

set weft yarn at index

Source

pub fn try_get_weft_yarn(&self, index: usize) -> Option<&Rc<Yarn>>

Get weft yarn at index. Returns None if not set via repeat or directly

Source

pub fn get_weft_yarn(&self, index: usize) -> &Rc<Yarn>

Get weft yarn at index

§Panics

If yarn is not set via repeat or directly

Source

pub fn set_warp_yarn_repeat<T>(&mut self, yarns: T)
where T: IntoIterator<Item = Yarn>,

Set the repeat of weft yarns

Source

pub fn set_warp_yarn_offset(&mut self, offset: usize)

set warp yarn repeat offset

Source

pub fn set_warp_yarn(&mut self, index: usize, yarn: Yarn)

set warp yarn at index

Source

pub fn try_get_warp_yarn(&self, index: usize) -> Option<&Rc<Yarn>>

Get warp yarn at index. Returns None if not set via repeat or directly

Source

pub fn get_warp_yarn(&self, index: usize) -> &Rc<Yarn>

Get warp yarn at index

§Panics

If yarn is not set via repeat or directly

Trait Implementations§

Source§

impl Clone for Draft

Source§

fn clone(&self) -> Draft

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 Draft

Source§

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

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

impl PartialEq for Draft

Source§

fn eq(&self, other: &Draft) -> 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 Draft

Auto Trait Implementations§

§

impl Freeze for Draft

§

impl RefUnwindSafe for Draft

§

impl !Send for Draft

§

impl !Sync for Draft

§

impl Unpin for Draft

§

impl UnwindSafe for Draft

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.