Struct xmp_toolkit::XmpMeta
source · [−]pub struct XmpMeta { /* private fields */ }
Expand description
The XmpMeta
struct allows access to the XMP Toolkit core services.
You can create XmpMeta
structs from metadata that you construct,
or that you obtain from files using the XmpFile
struct.
Implementations
sourceimpl XmpMeta
impl XmpMeta
sourcepub fn new() -> XmpResult<XmpMeta>
pub fn new() -> XmpResult<XmpMeta>
Creates a new, empty metadata struct.
An error result from this function is unlikely but possible if, for example, the C++ XMP Toolkit fails to initialize or reports an out-of-memory condition.
sourcepub fn from_file<P: AsRef<Path>>(path: P) -> XmpResult<Self>
pub fn from_file<P: AsRef<Path>>(path: P) -> XmpResult<Self>
Reads the XMP from a file without keeping the file open.
This is a convenience function for read-only workflows.
Arguments
path
: Path to the file to be read
sourcepub fn register_namespace(
namespace_uri: &str,
suggested_prefix: &str
) -> XmpResult<String>
pub fn register_namespace(
namespace_uri: &str,
suggested_prefix: &str
) -> XmpResult<String>
Registers a namespace URI with a suggested prefix.
If the URI is not registered but the suggested prefix is in use, a unique prefix is created from the suggested one. The actual registered prefix is returned. It is not an error if the URI is already registered, regardless of the prefix.
Arguments
-
namespace_uri
: The URI for the namespace. Must be a valid XML URI. -
suggested_prefix
: The suggested prefix to be used if the URI is not yet registered. Must be a valid XML name.
Returns the prefix actually registered for this URI.
sourcepub fn property(&self, schema_ns: &str, prop_name: &str) -> Option<String>
pub fn property(&self, schema_ns: &str, prop_name: &str) -> Option<String>
Gets a property value.
When specifying a namespace and path (in this and all other accessors):
- If a namespace URI is specified, it must be for a registered namespace.
- If the namespace is specified only by a prefix in the property name path, it must be a registered prefix.
- If both a URI and path prefix are present, they must be corresponding parts of a registered namespace.
Arguments
-
schema_ns
: The namespace URI for the property. The URI must be for a registered namespace. Must not be an empty string. -
prop_name
: The name of the property. Can be a general path expression. Must not be an empty string. The first component can be a namespace prefix; if present without aschema_ns
value, the prefix specifies the namespace. The prefix must be for a registered namespace, and if a namespace URI is specified, must match the registered prefix for that namespace.
Error handling
Any errors (for instance, empty or invalid namespace or property name)
are ignored; the function will return None
in such cases.
sourcepub fn set_property(
&mut self,
schema_ns: &str,
prop_name: &str,
prop_value: &str
) -> XmpResult<()>
pub fn set_property(
&mut self,
schema_ns: &str,
prop_name: &str,
prop_value: &str
) -> XmpResult<()>
Creates or sets a property value.
This is the simplest property setter. Use it for top-level simple properties.
Arguments
-
schema_ns
: The namespace URI; seeXmpMeta::property()
. -
prop_name
: The name of the property. Can be a general path expression. Must not be an empty string. SeeXmpMeta::property()
for namespace prefix usage. -
prop_value
: The new value.
sourcepub fn set_property_date(
&mut self,
schema_ns: &str,
prop_name: &str,
prop_value: &XmpDateTime
) -> XmpResult<()>
pub fn set_property_date(
&mut self,
schema_ns: &str,
prop_name: &str,
prop_value: &XmpDateTime
) -> XmpResult<()>
Creates or sets a property value using an XmpDateTime
structure.
This is the simplest property setter. Use it for top-level simple properties.
Arguments
-
schema_ns
: The namespace URI; seeXmpMeta::property()
. -
prop_name
: The name of the property. Can be a general path expression. Must not be an empty string. SeeXmpMeta::property()
for namespace prefix usage. -
prop_value
: The new value.
sourcepub fn does_property_exist(&self, schema_ns: &str, prop_name: &str) -> bool
pub fn does_property_exist(&self, schema_ns: &str, prop_name: &str) -> bool
Reports whether a property currently exists.
Arguments
-
schema_ns
: The namespace URI; seeXmpMeta::property()
. -
prop_name
: The name of the property. Can be a general path expression. Must not be an empty string. SeeXmpMeta::property()
for namespace prefix usage.
Error handling
Any errors (for instance, empty or invalid namespace or property name)
are ignored; the function will return false
in such cases.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for XmpMeta
impl !Send for XmpMeta
impl !Sync for XmpMeta
impl Unpin for XmpMeta
impl UnwindSafe for XmpMeta
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more