///|
/// A single attribute value list (RFC 4511 `PartialAttribute`).
pub struct PartialAttribute {
attr_type : String
values : Array[Bytes]
} derive(Eq, @debug.Debug)
///|
pub fn PartialAttribute::new(
attr_type : String,
values : Array[Bytes],
) -> PartialAttribute {
{ attr_type, values }
}
///|
pub fn PartialAttribute::single(
attr_type : String,
value : Bytes,
) -> PartialAttribute {
{ attr_type, values: [value] }
}
///|
/// Return the first value decoded as UTF-8 (lossy).
pub fn PartialAttribute::first_string(self : PartialAttribute) -> String? {
if self.values.is_empty() {
return None
}
Some(@utf8.decode_lossy(self.values[0][:]))
}
///|
/// An attribute with a required single value (RFC 4511 `Attribute`).
pub struct Attribute {
attr_type : String
values : Array[Bytes]
} derive(Eq, @debug.Debug)
///|
pub fn Attribute::new(attr_type : String, values : Array[Bytes]) -> Attribute {
{ attr_type, values }
}