Struct XmpFile

Source
pub struct XmpFile(/* private fields */);
Expand description

XmpFile extracts an XMP packet and reconciles metadata from the file.

use exempi2::{XmpFile, Xmp, CloseFlags, OpenFlags};

let mut xmpfile = XmpFile::new_from_file("file.jpg", OpenFlags::READ)
                 .expect("File to open");
let xmp = xmpfile.get_new_xmp().expect("an XMP packet");

xmpfile.close(CloseFlags::NONE).expect("File to close");

It also writes back the XMP packet

use exempi2::{XmpFile, Xmp, CloseFlags, OpenFlags, PropFlags};
let mut xmpfile = XmpFile::new_from_file("file.jpg", OpenFlags::FOR_UPDATE)
                 .expect("File to open");
let mut xmp = xmpfile.get_new_xmp().expect("an XMP packet");

xmp.set_property("some_schema", "some_property", "the value", PropFlags::NONE);
xmpfile.put_xmp(&xmp).expect("being able to put the XMP");
xmpfile.close(CloseFlags::SAFE_UPDATE);

Implementations§

Source§

impl XmpFile

Source

pub fn new() -> XmpFile

Create new XmpFile

Source

pub fn new_from_file<P: AsRef<OsStr>>( path: P, options: OpenFlags, ) -> Result<XmpFile>

Create and open a new XmpFile Equivalent to calling new then open. Return Err in case of failure

Source

pub fn open<P: AsRef<OsStr>>( &mut self, path: P, options: OpenFlags, ) -> Result<()>

Open an XmpFile. Usually called after new.

Source

pub fn close(&mut self, options: CloseFlags) -> Result<()>

Close the XmpFile

Source

pub fn is_null(&self) -> bool

Return true if native pointer is null

Source

pub fn get_new_xmp(&self) -> Result<Xmp>

Get a new XMP packet from the currently open file

Source

pub fn get_xmp(&self, xmp: &mut Xmp) -> Result<()>

Get the xmp data into an existing Xmp.

Source

pub fn get_xmp_xmpstring(&self) -> Result<(XmpString, PacketInfo)>

Get the xmp packet as a string.

Source

pub fn can_put_xmp(&self, xmp: &Xmp) -> bool

Return true if it can put the Xmp into the XmpFile.

Source

pub fn can_put_xmp_xmpstring(&self, xmp_packet: &XmpString) -> bool

Return true if it can put the XmpString packet into the XmpFile.

Source

pub fn can_put_xmp_str(&self, xmp_packet: &str) -> bool

Return true if it can put the XmpString packet into the XmpFile.

Source

pub fn put_xmp(&mut self, xmp: &Xmp) -> Result<()>

Put the Xmp into the XmpFile

Source

pub fn get_file_info( &self, file_path: &mut String, options: &mut OpenFlags, format: &mut FileType, handler_flags: &mut FormatOptionFlags, ) -> bool

Get info from the XmpFile.

Source

pub fn check_file_format<P: AsRef<OsStr>>(path: P) -> FileType

Check the file format for the specified path

Source

pub fn get_format_info(format: FileType) -> Result<FormatOptionFlags>

Get FormatOptions for the FileType

Trait Implementations§

Source§

impl Default for XmpFile

Source§

fn default() -> XmpFile

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

impl Drop for XmpFile

Source§

fn drop(&mut self)

Drop the XmpFile.

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, 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.