pub struct Dockerfile {
pub instructions: Vec<Instruction>,
}
Expand description
This struct represents a Dockerfile instance.
Fields§
§instructions: Vec<Instruction>
Implementations§
Source§impl Dockerfile
impl Dockerfile
Sourcepub const fn new(instructions: Vec<Instruction>) -> Self
pub const fn new(instructions: Vec<Instruction>) -> Self
Creates a new Dockerfile
instance for the given instructions.
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 path = PathBuf::from("./Dockerfile");
let dockerfile = Dockerfile::from(path)?;
dockerfile.to_json();
Ok(())
}
§Errors
Returns an error if the file cannot be opened or if there is a syntax error in the Dockerfile.
Sourcepub fn dump(&self, path: PathBuf) -> ParseResult<()>
pub fn dump(&self, path: PathBuf) -> ParseResult<()>
Dumps the instructions to a file.
If the file does not exist, it will be created. If the file exists, it will be overwritten.
§Errors
Returns an error if the file cannot be created or written to.
Sourcepub fn to_json(&self) -> ParseResult<()>
pub fn to_json(&self) -> ParseResult<()>
Writes the Dockerfile to the standard output in JSON format.
§Errors
Returns an error if the Dockerfile cannot be serialized to JSON.
Trait Implementations§
Source§impl Clone for Dockerfile
impl Clone for Dockerfile
Source§fn clone(&self) -> Dockerfile
fn clone(&self) -> Dockerfile
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Dockerfile
impl Debug for Dockerfile
Source§impl<'de> Deserialize<'de> for Dockerfile
impl<'de> Deserialize<'de> for Dockerfile
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 FromStr for Dockerfile
impl FromStr for Dockerfile
Source§impl PartialEq for Dockerfile
impl PartialEq for Dockerfile
Source§impl Serialize for Dockerfile
impl Serialize for Dockerfile
impl Eq for Dockerfile
impl StructuralPartialEq for Dockerfile
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