Enum Instruction

Source
pub enum Instruction {
    From(FromInstruction),
    Arg(ArgInstruction),
    Label(LabelInstruction),
    Run(RunInstruction),
    Entrypoint(EntrypointInstruction),
    Cmd(CmdInstruction),
    Copy(CopyInstruction),
    Env(EnvInstruction),
    Misc(MiscInstruction),
}
Expand description

A single Dockerfile instruction.

Individual instructions structures may be unpacked with pattern matching or via the TryFrom impls on each instruction type.

§Example

use std::convert::TryInto;
use dockerfile_parser::*;

let dockerfile = Dockerfile::parse("FROM alpine:3.11").unwrap();
let from: &FromInstruction = dockerfile.instructions
  .get(0).unwrap()
  .try_into().unwrap();

assert_eq!(from.image_parsed.tag, Some("3.11".to_string()));

Variants§

Implementations§

Source§

impl Instruction

Source

pub fn into_from(self) -> Option<FromInstruction>

Attempts to convert this instruction into a FromInstruction, returning None if impossible.

Source

pub fn as_from(&self) -> Option<&FromInstruction>

Attempts to convert this instruction into a FromInstruction, returning None if impossible.

Source

pub fn into_arg(self) -> Option<ArgInstruction>

Attempts to convert this instruction into an ArgInstruction, returning None if impossible.

Source

pub fn as_arg(&self) -> Option<&ArgInstruction>

Attempts to convert this instruction into an ArgInstruction, returning None if impossible.

Source

pub fn into_label(self) -> Option<LabelInstruction>

Attempts to convert this instruction into a LabelInstruction, returning None if impossible.

Source

pub fn as_label(&self) -> Option<&LabelInstruction>

Attempts to convert this instruction into a LabelInstruction, returning None if impossible.

Source

pub fn into_run(self) -> Option<RunInstruction>

Attempts to convert this instruction into a RunInstruction, returning None if impossible.

Source

pub fn as_run(&self) -> Option<&RunInstruction>

Attempts to convert this instruction into a RunInstruction, returning None if impossible.

Source

pub fn into_entrypoint(self) -> Option<EntrypointInstruction>

Attempts to convert this instruction into an EntrypointInstruction, returning None if impossible.

Source

pub fn as_entrypoint(&self) -> Option<&EntrypointInstruction>

Attempts to convert this instruction into an EntrypointInstruction, returning None if impossible.

Source

pub fn into_cmd(self) -> Option<CmdInstruction>

Attempts to convert this instruction into a CmdInstruction, returning None if impossible.

Source

pub fn as_cmd(&self) -> Option<&CmdInstruction>

Attempts to convert this instruction into a CmdInstruction, returning None if impossible.

Source

pub fn into_copy(self) -> Option<CopyInstruction>

Attempts to convert this instruction into a CopyInstruction, returning None if impossible.

Source

pub fn as_copy(&self) -> Option<&CopyInstruction>

Attempts to convert this instruction into a CopyInstruction, returning None if impossible.

Source

pub fn into_env(self) -> Option<EnvInstruction>

Attempts to convert this instruction into an EnvInstruction, returning None if impossible.

Source

pub fn as_env(&self) -> Option<&EnvInstruction>

Attempts to convert this instruction into an EnvInstruction, returning None if impossible.

Source

pub fn into_misc(self) -> Option<MiscInstruction>

Attempts to convert this instruction into a MiscInstruction, returning None if impossible.

Source

pub fn as_misc(&self) -> Option<&MiscInstruction>

Attempts to convert this instruction into a MiscInstruction, returning None if impossible.

Source

pub fn span(&self) -> Span

Gets the span of the instruction.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

Returns a copy 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 Instruction

Source§

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

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

impl From<ArgInstruction> for Instruction

Source§

fn from(ins: ArgInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<CmdInstruction> for Instruction

Source§

fn from(ins: CmdInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<CopyInstruction> for Instruction

Source§

fn from(ins: CopyInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<EntrypointInstruction> for Instruction

Source§

fn from(ins: EntrypointInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<EnvInstruction> for Instruction

Source§

fn from(ins: EnvInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<FromInstruction> for Instruction

Source§

fn from(ins: FromInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<LabelInstruction> for Instruction

Source§

fn from(ins: LabelInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<MiscInstruction> for Instruction

Source§

fn from(ins: MiscInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<RunInstruction> for Instruction

Source§

fn from(ins: RunInstruction) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> 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<'a> TryFrom<&'a Instruction> for &'a ArgInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a CmdInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a CopyInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a EnvInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a FromInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a LabelInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a MiscInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Instruction> for &'a RunInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: &'a Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Instruction> for EntrypointInstruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(instruction: Instruction) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pair<'_, Rule>> for Instruction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(record: Pair<'_, Rule>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Instruction

Source§

impl StructuralPartialEq for Instruction

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.