pub struct OciLayout { /* private fields */ }
Expand description
The oci layout JSON object serves as a marker for the base of an Open Container Image Layout and to provide the version of the image-layout in use. The imageLayoutVersion value will align with the OCI Image Specification version at the time changes to the layout are made, and will pin a given version until changes to the image layout are required.
Implementations§
source§impl OciLayout
impl OciLayout
sourcepub fn image_layout_version(&self) -> &String
pub fn image_layout_version(&self) -> &String
This REQUIRED property specifies the image layout version.
source§impl OciLayout
impl OciLayout
sourcepub fn set_image_layout_version(&mut self, val: String) -> &mut Self
pub fn set_image_layout_version(&mut self, val: String) -> &mut Self
This REQUIRED property specifies the image layout version.
source§impl OciLayout
impl OciLayout
sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<OciLayout>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<OciLayout>
Attempts to load an oci layout from a file.
§Errors
This function will return an OciSpecError::Io if the file does not exist or an OciSpecError::SerDe if the oci layout cannot be deserialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
sourcepub fn from_reader<R: Read>(reader: R) -> Result<OciLayout>
pub fn from_reader<R: Read>(reader: R) -> Result<OciLayout>
Attempts to load an oci layout from a stream.
§Errors
This function will return an OciSpecError::SerDe if the oci layout cannot be deserialized.
§Example
use oci_spec::image::OciLayout;
use std::fs::File;
let reader = File::open("oci-layout").unwrap();
let oci_layout = OciLayout::from_reader(reader).unwrap();
sourcepub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Attempts to write an oci layout to a file as JSON. If the file already exists, it will be overwritten.
§Errors
This function will return an OciSpecError::SerDe if the oci layout cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
oci_layout.to_file("oci-layout").unwrap();
sourcepub fn to_file_pretty<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn to_file_pretty<P: AsRef<Path>>(&self, path: P) -> Result<()>
Attempts to write an oci layout to a file as pretty printed JSON. If the file already exists, it will be overwritten.
§Errors
This function will return an OciSpecError::SerDe if the oci layout cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
oci_layout.to_file_pretty("my-oci-layout").unwrap();
sourcepub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>
Attempts to write an oci layout to a stream as JSON.
§Errors
This function will return an OciSpecError::SerDe if the oci layout cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
let mut writer = Vec::new();
oci_layout.to_writer(&mut writer);
sourcepub fn to_writer_pretty<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn to_writer_pretty<W: Write>(&self, writer: &mut W) -> Result<()>
Attempts to write an oci layout to a stream as pretty printed JSON.
§Errors
This function will return an OciSpecError::SerDe if the oci layout cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
let mut writer = Vec::new();
oci_layout.to_writer_pretty(&mut writer);
sourcepub fn to_string(&self) -> Result<String>
pub fn to_string(&self) -> Result<String>
Attempts to write an oci layout to a string as JSON.
§Errors
This function will return an OciSpecError::SerDe if the oci layout configuration cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
let json_str = oci_layout.to_string().unwrap();
sourcepub fn to_string_pretty(&self) -> Result<String>
pub fn to_string_pretty(&self) -> Result<String>
Attempts to write an oci layout to a string as pretty printed JSON.
§Errors
This function will return an OciSpecError::SerDe if the oci layout configuration cannot be serialized.
§Example
use oci_spec::image::OciLayout;
let oci_layout = OciLayout::from_file("oci-layout").unwrap();
let json_str = oci_layout.to_string_pretty().unwrap();
Trait Implementations§
source§impl<'de> Deserialize<'de> for OciLayout
impl<'de> Deserialize<'de> for OciLayout
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>,
source§impl PartialEq for OciLayout
impl PartialEq for OciLayout
impl Eq for OciLayout
impl StructuralPartialEq for OciLayout
Auto Trait Implementations§
impl Freeze for OciLayout
impl RefUnwindSafe for OciLayout
impl Send for OciLayout
impl Sync for OciLayout
impl Unpin for OciLayout
impl UnwindSafe for OciLayout
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)