Skip to main content

MetadataValue

Struct MetadataValue 

Source
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

Source

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.

Source

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.

Source

pub const fn i64(value: i64) -> Self

Creates a signed integer value.

Source

pub const fn u64(value: u64) -> Self

Creates an unsigned integer value.

Source

pub const fn decimal(value: DecimalValue) -> Self

Creates an exact decimal value.

Source

pub const fn boolean(value: bool) -> Self

Creates a boolean value.

Source

pub const fn timestamp(value: Timestamp) -> Self

Creates a timestamp value.

Source

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.

Source

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.

Source

pub const fn rational(value: RationalValue) -> Self

Creates an exact rational value.

Source

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.

Source

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.

Source

pub const fn reference(value: ObjectRef) -> Self

Creates a reference to another PostProject object.

Source

pub const fn kind(&self) -> MetadataValueKind

Returns the value’s inspectable type.

Source

pub fn as_string(&self) -> Option<&str>

Returns unqualified text, or None for another type.

Source

pub fn as_language_string(&self) -> Option<(&str, &str)>

Returns language-tagged text and its tag, or None for another type.

Source

pub const fn as_i64(&self) -> Option<i64>

Returns a signed integer, or None for another type.

Source

pub const fn as_u64(&self) -> Option<u64>

Returns an unsigned integer, or None for another type.

Source

pub const fn as_decimal(&self) -> Option<DecimalValue>

Returns an exact decimal, or None for another type.

Source

pub const fn as_bool(&self) -> Option<bool>

Returns a boolean, or None for another type.

Source

pub const fn as_timestamp(&self) -> Option<Timestamp>

Returns a timestamp, or None for another type.

Source

pub fn as_uri(&self) -> Option<&str>

Returns URI text, or None for another type.

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Returns opaque bytes, or None for another type.

Source

pub const fn as_rational(&self) -> Option<RationalValue>

Returns an exact rational, or None for another type.

Source

pub fn as_list(&self) -> Option<&[Self]>

Returns ordered list items, or None for another type.

Source

pub fn as_structure(&self) -> Option<&[MetadataField]>

Returns ordered structured fields, or None for another type.

Source

pub const fn as_reference(&self) -> Option<ObjectRef>

Returns an object reference, or None for another type.

Source

pub const fn nesting_depth(&self) -> usize

Returns this value’s nesting depth, including the root value.

Source

pub const fn payload_bytes(&self) -> usize

Returns the bounded aggregate payload size used for validation.

Trait Implementations§

Source§

impl Clone for MetadataValue

Source§

fn clone(&self) -> MetadataValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetadataValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MetadataValue

Source§

impl Hash for MetadataValue

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MetadataValue

Source§

fn eq(&self, other: &MetadataValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for MetadataValue

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.