pub trait SpecifiedValueInfo {
    const SUPPORTED_TYPES: u8 = 0u8;

    // Provided method
    fn collect_completion_keywords(_f: KeywordsCollectFn<'_>) { ... }
}
Expand description

Information of values of a given specified value type.

This trait is derivable with #[derive(SpecifiedValueInfo)].

The algorithm traverses the type definition. For SUPPORTED_TYPES, it puts an or’ed value of SUPPORTED_TYPES of all types it finds. For collect_completion_keywords, it recursively invokes this method on types found, and lists all keyword values and function names following the same rule as ToCss in that method.

Some attributes of ToCss can affect the behavior, specifically:

  • If #[css(function)] is found, the content inside the annotated variant (or the whole type) isn’t traversed, only the function name is listed in collect_completion_keywords.
  • If #[css(skip)] is found, the content inside the variant or field is ignored.
  • Values listed in #[css(if_empty)], #[parse(aliases)], and #[css(keyword)] are added into collect_completion_keywords.

In addition to css attributes, it also has value_info helper attributes, including:

  • #[value_info(ty = "TYPE")] can be used to specify a constant from CssType to SUPPORTED_TYPES.
  • #[value_info(other_values = "value1,value2")] can be used to add other values related to a field, variant, or the type itself into collect_completion_keywords.
  • #[value_info(starts_with_keyword)] can be used on variants to add the name of a non-unit variant (serialized like ToCss) into collect_completion_keywords.

Provided Associated Constants§

source

const SUPPORTED_TYPES: u8 = 0u8

Supported CssTypes by the given value type.

XXX This should be typed CssType when that becomes a bitflags. Currently we cannot do so since bitflags cannot be used in constant.

Provided Methods§

source

fn collect_completion_keywords(_f: KeywordsCollectFn<'_>)

Collect value starting words for the given specified value type. This includes keyword and function names which can appear at the beginning of a value of this type.

Caller should pass in a callback function to accept the list of values. The callback function can be called multiple times, and some values passed to the callback may be duplicate.

Implementations on Foreign Types§

source§

impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T>

source§

impl SpecifiedValueInfo for str

source§

impl<T: SpecifiedValueInfo> SpecifiedValueInfo for [T]

source§

impl SpecifiedValueInfo for u8

source§

impl SpecifiedValueInfo for bool

source§

impl SpecifiedValueInfo for Url

source§

impl SpecifiedValueInfo for usize

source§

impl SpecifiedValueInfo for Atom

source§

impl SpecifiedValueInfo for f32

source§

impl<T: SpecifiedValueInfo> SpecifiedValueInfo for Arc<T>

source§

impl<T1, T2> SpecifiedValueInfo for (T1, T2)where T1: SpecifiedValueInfo, T2: SpecifiedValueInfo,

source§

impl<T: SpecifiedValueInfo> SpecifiedValueInfo for Vec<T>

source§

impl<T: SpecifiedValueInfo> SpecifiedValueInfo for Arc<T>

source§

impl<Idx: SpecifiedValueInfo> SpecifiedValueInfo for Range<Idx>

source§

impl SpecifiedValueInfo for u32

source§

impl SpecifiedValueInfo for u16

source§

impl SpecifiedValueInfo for i8

source§

impl<T: SpecifiedValueInfo> SpecifiedValueInfo for Option<T>

source§

impl SpecifiedValueInfo for String

source§

impl SpecifiedValueInfo for i32

Implementors§