pub struct GCode<A = DefaultArguments> { /* private fields */ }
Expand description
The in-memory representation of a single command in the G-code language
(e.g. "G01 X50.0 Y-20.0"
).
Implementations§
Source§impl<A: Buffer<Word>> GCode<A>
impl<A: Buffer<Word>> GCode<A>
Sourcepub fn new_with_argument_buffer(
mnemonic: Mnemonic,
number: f32,
span: Span,
arguments: A,
) -> Self
pub fn new_with_argument_buffer( mnemonic: Mnemonic, number: f32, span: Span, arguments: A, ) -> Self
Sourcepub fn major_number(&self) -> u32
pub fn major_number(&self) -> u32
The integral part of a command number (i.e. the 12
in G12.3
).
Sourcepub fn minor_number(&self) -> u32
pub fn minor_number(&self) -> u32
The fractional part of a command number (i.e. the 3
in G12.3
).
Sourcepub fn push_argument(&mut self, arg: Word) -> Result<(), CapacityError<Word>>
pub fn push_argument(&mut self, arg: Word) -> Result<(), CapacityError<Word>>
Add an argument to the list of arguments attached to this GCode
.
Sourcepub fn with_argument(self, arg: Word) -> Self
pub fn with_argument(self, arg: Word) -> Self
The builder equivalent of GCode::push_argument()
.
§Panics
This will panic if the underlying Buffer
returns a
CapacityError
.
Sourcepub fn value_for(&self, letter: char) -> Option<f32>
pub fn value_for(&self, letter: char) -> Option<f32>
Get the value for a particular argument.
§Examples
let gcode = GCode::new(Mnemonic::General, 1.0, Span::PLACEHOLDER)
.with_argument(Word::new('X', 30.0, Span::PLACEHOLDER))
.with_argument(Word::new('Y', -3.14, Span::PLACEHOLDER));
assert_eq!(gcode.value_for('Y'), Some(-3.14));
Trait Implementations§
Source§impl<'de, A> Deserialize<'de> for GCode<A>where
A: Deserialize<'de>,
impl<'de, A> Deserialize<'de> for GCode<A>where
A: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<A: Buffer<Word>> Extend<Word> for GCode<A>
impl<A: Buffer<Word>> Extend<Word> for GCode<A>
Source§fn extend<I: IntoIterator<Item = Word>>(&mut self, words: I)
fn extend<I: IntoIterator<Item = Word>>(&mut self, words: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl<A> Freeze for GCode<A>where
A: Freeze,
impl<A> RefUnwindSafe for GCode<A>where
A: RefUnwindSafe,
impl<A> Send for GCode<A>where
A: Send,
impl<A> Sync for GCode<A>where
A: Sync,
impl<A> Unpin for GCode<A>where
A: Unpin,
impl<A> UnwindSafe for GCode<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more