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 const fn new(path: PathBuf, instructions: Vec<Instruction>) -> Self
pub const 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 const fn empty(path: PathBuf) -> Self
pub const 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);
Ok(())
}
§Errors
Returns an error if the file cannot be opened or if there is a syntax error in the Dockerfile.
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(())
}
§Errors
Returns an error if the file cannot be opened or if there is a syntax error in the Dockerfile.
Trait Implementations§
Source§impl Clone for Dockerfile
impl Clone for Dockerfile
Source§fn clone(&self) -> Dockerfile
fn clone(&self) -> Dockerfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more