pub struct Draft { /* private fields */ }Expand description
Structure holding all elements of a draft
Implementations§
Source§impl Draft
impl Draft
Sourcepub fn new(
shaft_count: u32,
tie_up_create: TieUpCreate,
rise_sink: RiseSink,
) -> Self
pub fn new( shaft_count: u32, tie_up_create: TieUpCreate, rise_sink: RiseSink, ) -> Self
Create an empty draft with the given options
Sourcepub fn treadling_info(&self) -> &TreadlingInfo
pub fn treadling_info(&self) -> &TreadlingInfo
Get the treadling
Sourcepub fn make_rising(&mut self)
pub fn make_rising(&mut self)
Make rising shaft
Sourcepub fn make_sinking(&mut self)
pub fn make_sinking(&mut self)
Make sinking shaft
Sourcepub fn make_lift_plan(&mut self) -> bool
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
Sourcepub fn max_shaft(&self) -> (WeavingAxis, u32)
pub fn max_shaft(&self) -> (WeavingAxis, u32)
Max shaft used in threading or treadling
Sourcepub fn set_shaft_count(
&mut self,
shaft_count: u32,
) -> Result<(), (WeavingAxis, u32)>
pub fn set_shaft_count( &mut self, shaft_count: u32, ) -> Result<(), (WeavingAxis, u32)>
Sourcepub fn splice_threading<R>(
&mut self,
range: R,
replace_with: &[u32],
) -> Result<Vec<u32>, usize>where
R: RangeBounds<usize>,
pub fn splice_threading<R>(
&mut self,
range: R,
replace_with: &[u32],
) -> Result<Vec<u32>, usize>where
R: RangeBounds<usize>,
Sourcepub fn try_insert_threading(
&mut self,
shaft: Shaft,
index: usize,
) -> Result<Result<(), Shaft>, usize>
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
Sourcepub fn remove_threading(&mut self, index: usize) -> Shaft
pub fn remove_threading(&mut self, index: usize) -> Shaft
Sourcepub fn get_from_threading(&self, index: usize) -> Option<&u32>
pub fn get_from_threading(&self, index: usize) -> Option<&u32>
Get threading shaft at an index
Sourcepub fn put_threading(&mut self, index: usize, shaft: Shaft) -> Shaft
pub fn put_threading(&mut self, index: usize, shaft: Shaft) -> Shaft
Sourcepub fn try_put_threading(
&mut self,
index: usize,
shaft: Shaft,
) -> Result<Option<Shaft>, usize>
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
Sourcepub fn flip_threading_vert(&mut self)
pub fn flip_threading_vert(&mut self)
Sourcepub fn mirror_threading(&mut self)
pub fn mirror_threading(&mut self)
Sourcepub fn flip_threading_horiz(&mut self)
pub fn flip_threading_horiz(&mut self)
Sourcepub fn push_single_treadling(&mut self, treadle: u32) -> Result<(), u32>
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
Sourcepub fn push_treadling(&mut self, treadles: HashSet<u32>) -> Result<(), u32>
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
Sourcepub fn splice_treadling<R>(
&mut self,
range: R,
replace_with: Vec<HashSet<u32>>,
) -> Result<Vec<HashSet<u32>>, u32>where
R: RangeBounds<usize>,
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
Sourcepub fn put_treadling(
&mut self,
index: usize,
treadles: HashSet<u32>,
) -> Result<Option<HashSet<u32>>, u32>
pub fn put_treadling( &mut self, index: usize, treadles: HashSet<u32>, ) -> Result<Option<HashSet<u32>>, u32>
Sourcepub fn yarn_palette(&self) -> &YarnPalette
pub fn yarn_palette(&self) -> &YarnPalette
Get yarn palette
Sourcepub fn weft_yarns(&self) -> &YarnSequence
pub fn weft_yarns(&self) -> &YarnSequence
Get weft yarns
Sourcepub fn warp_yarns(&self) -> &YarnSequence
pub fn warp_yarns(&self) -> &YarnSequence
Get warp yarns
Sourcepub fn set_weft_yarn_repeat<T>(&mut self, yarns: T)where
T: IntoIterator<Item = Yarn>,
pub fn set_weft_yarn_repeat<T>(&mut self, yarns: T)where
T: IntoIterator<Item = Yarn>,
Set the repeat of weft yarns
Sourcepub fn set_weft_yarn_offset(&mut self, offset: usize)
pub fn set_weft_yarn_offset(&mut self, offset: usize)
set weft yarn repeat offset
Sourcepub fn set_weft_yarn(&mut self, index: usize, yarn: Yarn)
pub fn set_weft_yarn(&mut self, index: usize, yarn: Yarn)
set weft yarn at index
Sourcepub fn try_get_weft_yarn(&self, index: usize) -> Option<&Rc<Yarn>>
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
Sourcepub fn get_weft_yarn(&self, index: usize) -> &Rc<Yarn>
pub fn get_weft_yarn(&self, index: usize) -> &Rc<Yarn>
Sourcepub fn set_warp_yarn_repeat<T>(&mut self, yarns: T)where
T: IntoIterator<Item = Yarn>,
pub fn set_warp_yarn_repeat<T>(&mut self, yarns: T)where
T: IntoIterator<Item = Yarn>,
Set the repeat of weft yarns
Sourcepub fn set_warp_yarn_offset(&mut self, offset: usize)
pub fn set_warp_yarn_offset(&mut self, offset: usize)
set warp yarn repeat offset
Sourcepub fn set_warp_yarn(&mut self, index: usize, yarn: Yarn)
pub fn set_warp_yarn(&mut self, index: usize, yarn: Yarn)
set warp yarn at index