[][src]Struct gcode::GCode

pub struct GCode<A = DefaultArguments> { /* fields omitted */ }

The in-memory representation of a single command in the G-code language (e.g. "G01 X50.0 Y-20.0").

Methods

impl GCode[src]

pub fn new(mnemonic: Mnemonic, number: f32, span: Span) -> Self[src]

Create a new GCode which uses the DefaultArguments buffer.

impl<A: Buffer<Word>> GCode<A>[src]

pub fn new_with_argument_buffer(
    mnemonic: Mnemonic,
    number: f32,
    span: Span,
    arguments: A
) -> Self
[src]

Create a new GCode which uses a custom Buffer.

pub fn mnemonic(&self) -> Mnemonic[src]

The overall category this GCode belongs to.

pub fn major_number(&self) -> u32[src]

The integral part of a command number (i.e. the 12 in G12.3).

pub fn minor_number(&self) -> u32[src]

The fractional part of a command number (i.e. the 3 in G12.3).

pub fn arguments(&self) -> &[Word][src]

The arguments attached to this GCode.

pub fn span(&self) -> Span[src]

Where the GCode was found in its source text.

pub fn push_argument(&mut self, arg: Word) -> Result<(), CapacityError<Word>>[src]

Add an argument to the list of arguments attached to this GCode.

pub fn with_argument(self, arg: Word) -> Self[src]

The builder equivalent of GCode::push_argument().

Panics

This will panic if the underlying Buffer returns a CapacityError.

pub fn value_for(&self, letter: char) -> Option<f32>[src]

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

impl<A: Clone> Clone for GCode<A>[src]

impl<A: Buffer<Word>> Debug for GCode<A>[src]

impl<'de, A> Deserialize<'de> for GCode<A> where
    A: Deserialize<'de>, 
[src]

impl<A: Buffer<Word>> Display for GCode<A>[src]

impl<A: Buffer<Word>> Extend<Word> for GCode<A>[src]

impl<A: PartialEq> PartialEq<GCode<A>> for GCode<A>[src]

impl<A> Serialize for GCode<A> where
    A: Serialize
[src]

impl<A> StructuralPartialEq for GCode<A>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.