pub struct MetadataValue { /* private fields */ }Expand description
A bounded, recursively typed metadata value.
Constructors preserve ordering and exact text while enforcing limits. The private representation prevents callers from bypassing those invariants.
Implementations§
Source§impl MetadataValue
impl MetadataValue
Sourcepub fn string(value: impl Into<String>) -> Result<Self>
pub fn string(value: impl Into<String>) -> Result<Self>
Creates an unqualified text value.
§Errors
Returns ErrorKind::InvalidArgument when the text exceeds its byte
limit or contains NUL.
Sourcepub fn language_string(
value: impl Into<String>,
language: impl Into<String>,
) -> Result<Self>
pub fn language_string( value: impl Into<String>, language: impl Into<String>, ) -> Result<Self>
Creates language-tagged text with a syntax-safe BCP 47-shaped tag.
§Errors
Returns ErrorKind::InvalidArgument when the text is invalid or the
language tag is empty, oversized, or not syntactically safe.
Sourcepub const fn decimal(value: DecimalValue) -> Self
pub const fn decimal(value: DecimalValue) -> Self
Creates an exact decimal value.
Sourcepub fn uri(value: impl Into<String>) -> Result<Self>
pub fn uri(value: impl Into<String>) -> Result<Self>
Creates a URI value while preserving its exact spelling.
§Errors
Returns ErrorKind::InvalidArgument when the URI is invalid,
oversized, or contains NUL.
Sourcepub fn bytes(value: Vec<u8>) -> Result<Self>
pub fn bytes(value: Vec<u8>) -> Result<Self>
Creates an opaque binary value.
§Errors
Returns ErrorKind::InvalidArgument when the value exceeds
MAX_METADATA_BINARY_BYTES.
Sourcepub const fn rational(value: RationalValue) -> Self
pub const fn rational(value: RationalValue) -> Self
Creates an exact rational value.
Sourcepub fn list(values: Vec<Self>) -> Result<Self>
pub fn list(values: Vec<Self>) -> Result<Self>
Creates an ordered list.
§Errors
Returns ErrorKind::InvalidArgument when the item count, aggregate
payload size, or nesting depth exceeds its documented limit.
Sourcepub fn structure(fields: Vec<MetadataField>) -> Result<Self>
pub fn structure(fields: Vec<MetadataField>) -> Result<Self>
Creates an ordered structured value.
§Errors
Returns ErrorKind::InvalidArgument when the field count, aggregate
payload size, or nesting depth exceeds its documented limit.
Sourcepub const fn reference(value: ObjectRef) -> Self
pub const fn reference(value: ObjectRef) -> Self
Creates a reference to another PostProject object.
Sourcepub const fn kind(&self) -> MetadataValueKind
pub const fn kind(&self) -> MetadataValueKind
Returns the value’s inspectable type.
Sourcepub fn as_language_string(&self) -> Option<(&str, &str)>
pub fn as_language_string(&self) -> Option<(&str, &str)>
Returns language-tagged text and its tag, or None for another type.
Sourcepub const fn as_u64(&self) -> Option<u64>
pub const fn as_u64(&self) -> Option<u64>
Returns an unsigned integer, or None for another type.
Sourcepub const fn as_decimal(&self) -> Option<DecimalValue>
pub const fn as_decimal(&self) -> Option<DecimalValue>
Returns an exact decimal, or None for another type.
Sourcepub const fn as_timestamp(&self) -> Option<Timestamp>
pub const fn as_timestamp(&self) -> Option<Timestamp>
Returns a timestamp, or None for another type.
Sourcepub const fn as_rational(&self) -> Option<RationalValue>
pub const fn as_rational(&self) -> Option<RationalValue>
Returns an exact rational, or None for another type.
Sourcepub fn as_structure(&self) -> Option<&[MetadataField]>
pub fn as_structure(&self) -> Option<&[MetadataField]>
Returns ordered structured fields, or None for another type.
Sourcepub const fn as_reference(&self) -> Option<ObjectRef>
pub const fn as_reference(&self) -> Option<ObjectRef>
Returns an object reference, or None for another type.
Sourcepub const fn nesting_depth(&self) -> usize
pub const fn nesting_depth(&self) -> usize
Returns this value’s nesting depth, including the root value.
Sourcepub const fn payload_bytes(&self) -> usize
pub const fn payload_bytes(&self) -> usize
Returns the bounded aggregate payload size used for validation.
Trait Implementations§
Source§impl Clone for MetadataValue
impl Clone for MetadataValue
Source§fn clone(&self) -> MetadataValue
fn clone(&self) -> MetadataValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more