pub struct Dockerfile {
pub path: PathBuf,
pub instructions: Vec<Instruction>,
}
Expand description
This struct represents a Dockerfile instance.
Fields§
§path: PathBuf
§instructions: Vec<Instruction>
Implementations§
Source§impl Dockerfile
impl Dockerfile
Sourcepub fn new(path: PathBuf, instructions: Vec<Instruction>) -> Self
pub fn new(path: PathBuf, instructions: Vec<Instruction>) -> Self
Creates a new Dockerfile
instance for the given path and instructions.
The actual file does not need to exist at this point.
Sourcepub fn empty(path: PathBuf) -> Self
pub fn empty(path: PathBuf) -> Self
Creates an empty Dockerfile
instance for the given path.
The actual file does not need to exist at this point.
Sourcepub fn from(path: PathBuf) -> ParseResult<Self>
pub fn from(path: PathBuf) -> ParseResult<Self>
Parses the content of the Dockerfile and returns a populated Dockerfile
instance.
The file is read line by line, preserving empty lines and comments.
§Example
use std::path::PathBuf;
use dockerfile_parser_rs::Dockerfile;
use dockerfile_parser_rs::ParseResult;
fn main() -> ParseResult<()> {
let dockerfile = Dockerfile::from(PathBuf::from("./Dockerfile"))?;
println!("{:#?}", dockerfile.instructions);
Ok(())
}
Sourcepub fn parse(&self) -> ParseResult<Vec<Instruction>>
pub fn parse(&self) -> ParseResult<Vec<Instruction>>
Parses the content of the Dockerfile and returns a vector of Instruction
items.
The file is read line by line, preserving empty lines and comments.
The attributes of the Dockerfile
instance are not modified by this method.
§Example
use std::path::PathBuf;
use dockerfile_parser_rs::Dockerfile;
use dockerfile_parser_rs::ParseResult;
fn main() -> ParseResult<()> {
let dockerfile = Dockerfile::empty(PathBuf::from("./Dockerfile"));
let instructions = dockerfile.parse()?;
println!("{:#?}", instructions);
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dockerfile
impl RefUnwindSafe for Dockerfile
impl Send for Dockerfile
impl Sync for Dockerfile
impl Unpin for Dockerfile
impl UnwindSafe for Dockerfile
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