Trait darling::FromMetaItem
[−]
[src]
pub trait FromMetaItem { fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error> { ... } fn from_meta_item(item: &MetaItem) -> Result<Self, Error> { ... } fn from_word() -> Result<Self, Error> { ... } fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error> { ... } fn from_value(value: &Lit) -> Result<Self, Error> { ... } fn from_char(value: char) -> Result<Self, Error> { ... } fn from_string(value: &str) -> Result<Self, Error> { ... } fn from_bool(value: bool) -> Result<Self, Error> { ... } }
Create an instance from an item in an attribute declaration.
Implementing FromMetaItem
- Do not take a dependency on the
ident
of the passed-in meta item. The ident will be set by the field name of the containing struct. - Implement only the
from_*
methods that you intend to support. The default implementations will return useful errors.
Provided Implementations
bool
- Word with no value specified - becomes
true
. - As a boolean literal, e.g.
foo = true
. - As a string literal, e.g.
foo = "true"
.
String
- As a string literal, e.g.
foo = "hello"
. - As a raw string literal, e.g.
foo = r#"hello "world""#
.
()
- Word with no value specified, e.g.
foo
. This is best used withOption
. Seedarling::util::Flag
for a more strongly-typed alternative.
Option
- Any format produces
Some
.
Result<T, darling::Error>
- Allows for fallible parsing; will populate the target field with the result of the parse attempt.
Provided Methods
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
Create an instance from a syn::MetaItem
by dispatching to the format-appropriate
trait function. This generally should not be overridden by implementers.
fn from_word() -> Result<Self, Error>
Create an instance from the presence of the word in the attribute with no additional options specified.
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
Create an instance from a list of nested meta items.
fn from_value(value: &Lit) -> Result<Self, Error>
Create an instance from a literal value of either foo = "bar"
or foo("bar")
.
This dispatches to the appropriate method based on the type of literal encountered,
and generally should not be overridden by implementers.
fn from_char(value: char) -> Result<Self, Error>
Create an instance from a char literal in a value position.
fn from_string(value: &str) -> Result<Self, Error>
Create an instance from a string literal in a value position.
fn from_bool(value: bool) -> Result<Self, Error>
Create an instance from a bool literal in a value position.
Implementations on Foreign Types
impl FromMetaItem for i16
[src]
fn from_string(s: &str) -> Result<i16, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for u16
[src]
fn from_string(s: &str) -> Result<u16, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for i64
[src]
fn from_string(s: &str) -> Result<i64, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for bool
[src]
fn from_word() -> Result<bool, Error>
[src]
fn from_bool(value: bool) -> Result<bool, Error>
[src]
fn from_string(value: &str) -> Result<bool, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
impl FromMetaItem for i32
[src]
fn from_string(s: &str) -> Result<i32, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Result<T, MetaItem> where
T: FromMetaItem,
[src]
T: FromMetaItem,
Parses the meta-item, and in case of error preserves a copy of the input for later analysis.
fn from_meta_item(item: &MetaItem) -> Result<Result<T, MetaItem>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Option<T> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<Option<T>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for u32
[src]
fn from_string(s: &str) -> Result<u32, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for i8
[src]
fn from_string(s: &str) -> Result<i8, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for TyParamBound
[src]
fn from_string(value: &str) -> Result<TyParamBound, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for usize
[src]
fn from_string(s: &str) -> Result<usize, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for WhereClause
[src]
fn from_string(value: &str) -> Result<WhereClause, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for RefCell<T> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<RefCell<T>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for Ident
[src]
fn from_string(value: &str) -> Result<Ident, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for AtomicBool
[src]
fn from_meta_item(mi: &MetaItem) -> Result<AtomicBool, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for String
[src]
fn from_string(s: &str) -> Result<String, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Rc<T> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<Rc<T>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for u64
[src]
fn from_string(s: &str) -> Result<u64, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<V> FromMetaItem for HashMap<String, V, RandomState> where
V: FromMetaItem,
[src]
V: FromMetaItem,
fn from_list(
nested: &[NestedMetaItem]
) -> Result<HashMap<String, V, RandomState>, Error>
[src]
nested: &[NestedMetaItem]
) -> Result<HashMap<String, V, RandomState>, Error>
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Result<T, Error> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<Result<T, Error>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for ForwardAttrs
[src]
fn from_word() -> Result<ForwardAttrs, Error>
[src]
fn from_list(nested: &[NestedMetaItem]) -> Result<ForwardAttrs, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for RenameRule
[src]
fn from_string(value: &str) -> Result<RenameRule, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Box<T> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<Box<T>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for isize
[src]
fn from_string(s: &str) -> Result<isize, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for DataShape
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<DataShape, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for u8
[src]
fn from_string(s: &str) -> Result<u8, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for Path
[src]
fn from_string(value: &str) -> Result<Path, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for ()
[src]
fn from_word() -> Result<(), Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for MetaItem
[src]
fn from_meta_item(value: &MetaItem) -> Result<MetaItem, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl<T> FromMetaItem for Arc<T> where
T: FromMetaItem,
[src]
T: FromMetaItem,
fn from_meta_item(item: &MetaItem) -> Result<Arc<T>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for Vec<WherePredicate>
[src]
fn from_string(value: &str) -> Result<Vec<WherePredicate>, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
impl FromMetaItem for Shape
[src]
fn from_list(items: &[NestedMetaItem]) -> Result<Shape, Error>
[src]
fn from_nested_meta_item(item: &NestedMetaItem) -> Result<Self, Error>
[src]
fn from_meta_item(item: &MetaItem) -> Result<Self, Error>
[src]
fn from_word() -> Result<Self, Error>
[src]
fn from_value(value: &Lit) -> Result<Self, Error>
[src]
fn from_char(value: char) -> Result<Self, Error>
[src]
fn from_string(value: &str) -> Result<Self, Error>
[src]
fn from_bool(value: bool) -> Result<Self, Error>
[src]
Implementors
impl FromMetaItem for Flag
impl<T> FromMetaItem for Override<T> where
T: FromMetaItem,impl FromMetaItem for IdentList
impl FromMetaItem for Ignored