Enum compose_spec::ListOrMap

source ·
pub enum ListOrMap {
    List(IndexSet<String>),
    Map(Map),
}
Expand description

A list of unique strings or a map with optional single values.

Variants§

§

List(IndexSet<String>)

List of unique strings.

§

Map(Map)

Map with optional single values.

Implementations§

source§

impl ListOrMap

source

pub fn is_empty(&self) -> bool

Returns true if the list or map contain no elements.

source

pub const fn as_list(&self) -> Option<&IndexSet<String>>

Return Some if a list.

source

pub const fn as_map(&self) -> Option<&Map>

Return Some if a map.

source

pub fn into_list(self) -> IndexSet<String>

Convert into a list.

If a map, a new IndexSet is created by joining keys and values with an = character, like so {key}={value}. If the value is None, the key is put into the list as is.

All places ListOrMap is used within Compose support the use of the {key}={value} syntax.

source

pub fn into_map(self) -> Result<Map, InvalidMapKeyError>

Attempt to convert into a map.

Split list items into keys and values on the ‘=’ character, i.e. {key}={value}. If an item does not contain ‘=’, then the whole item is used as the key and the value is None. If the value is an empty string, then it will also be converted to None.

Alias for self.into_map_split_on(&['=']).

§Errors

Returns an error if a key is not a valid MapKey.

source

pub fn into_map_split_on( self, delimiters: &[char] ) -> Result<Map, InvalidMapKeyError>

Attempt to convert into a map.

Split list items into keys and values with the delimiters. If an item does not contain a delimiter, then the whole item is used as the key and the value is None. If the value is an empty string, then it will also be converted to None.

§Errors

Returns an error if a key is not a valid MapKey.

Trait Implementations§

source§

impl Clone for ListOrMap

source§

fn clone(&self) -> ListOrMap

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ListOrMap

source§

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

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

impl Default for ListOrMap

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ListOrMap

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for ListOrMap

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ListOrMap

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for ListOrMap

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> 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,

§

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>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,