pub enum AttributeValue {
Null,
String(String),
BytesHex(Vec<u8>),
BytesBase64(Vec<u8>),
Int(i32),
IntHex(u32),
Long(i64),
LongHex(u64),
Float(f32),
Double(f64),
Boolean(bool),
}Expand description
The typed payload of an XML attribute.
Variants§
Null
No value (AOSP’s TYPE_NULL).
String(String)
A plain UTF-8 string.
BytesHex(Vec<u8>)
Bytes whose canonical text form is lowercase hex.
BytesBase64(Vec<u8>)
Bytes whose canonical text form is Base64.
Int(i32)
A 32-bit signed integer, rendered in decimal.
IntHex(u32)
A 32-bit value rendered in hex — see AttributeValue::as_str for
the signed-magnitude rendering rule this follows.
Long(i64)
A 64-bit signed integer, rendered in decimal.
LongHex(u64)
A 64-bit value rendered in hex — see AttributeValue::as_str for
the signed-magnitude rendering rule this follows.
Float(f32)
A 32-bit floating-point value.
Double(f64)
A 64-bit floating-point value.
Boolean(bool)
A boolean, rendered as "true"/"false".
Implementations§
Source§impl AttributeValue
impl AttributeValue
Sourcepub fn as_str(&self) -> Cow<'_, str>
pub fn as_str(&self) -> Cow<'_, str>
Render the value as a human-readable string, mirroring the original Java serializer’s output.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns the inner string if this is AttributeValue::String, else None.
Sourcepub fn as_int(&self) -> Option<i32>
pub fn as_int(&self) -> Option<i32>
Returns the inner value if this is AttributeValue::Int, else None.
Sourcepub fn as_int_hex(&self) -> Option<u32>
pub fn as_int_hex(&self) -> Option<u32>
Returns the inner value if this is AttributeValue::IntHex, else None.
Sourcepub fn as_long(&self) -> Option<i64>
pub fn as_long(&self) -> Option<i64>
Returns the inner value if this is AttributeValue::Long, else None.
Sourcepub fn as_long_hex(&self) -> Option<u64>
pub fn as_long_hex(&self) -> Option<u64>
Returns the inner value if this is AttributeValue::LongHex, else None.
Sourcepub fn as_float(&self) -> Option<f32>
pub fn as_float(&self) -> Option<f32>
Returns the inner value if this is AttributeValue::Float, else None.
Sourcepub fn as_double(&self) -> Option<f64>
pub fn as_double(&self) -> Option<f64>
Returns the inner value if this is AttributeValue::Double, else None.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the inner value if this is AttributeValue::Boolean, else None.
Sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Returns the inner bytes if this is AttributeValue::BytesHex or
AttributeValue::BytesBase64, else None.
Trait Implementations§
Source§impl Clone for AttributeValue
impl Clone for AttributeValue
Source§fn clone(&self) -> AttributeValue
fn clone(&self) -> AttributeValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more