Skip to main content

Package

Struct Package 

Source
pub struct Package { /* private fields */ }
Expand description

Represents an OPC package (ZIP file)

Implementations§

Source§

impl Package

Source

pub fn new() -> Self

Create a new empty package

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open a package from a file path

Source

pub fn open_reader<R: Read + Seek>(reader: R) -> Result<Self>

Open a package from a reader

Source

pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>

Save the package to a file

Source

pub fn save_writer<W: Write + Seek>(&self, writer: W) -> Result<()>

Save the package to a writer

Source

pub fn get_part(&self, path: &str) -> Option<&[u8]>

Get a part by path

Source

pub fn add_part(&mut self, path: String, content: Vec<u8>)

Add or update a part

Source

pub fn remove_part(&mut self, path: &str) -> Option<Vec<u8>>

Remove a part by path

Source

pub fn has_part(&self, path: &str) -> bool

Check if a part exists

Source

pub fn part_paths(&self) -> Vec<&str>

Get all part paths

Source

pub fn part_count(&self) -> usize

Get number of parts

Source

pub fn get_part_mut(&mut self, path: &str) -> Option<&mut Vec<u8>>

Get mutable reference to part content

Source

pub fn get_part_string(&self, path: &str) -> Option<String>

Get part as string (for XML parts)

Trait Implementations§

Source§

impl Default for Package

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.