Trait darling_core::FromMeta
[−]
[src]
pub trait FromMeta: Sized { fn from_nested_meta(item: &NestedMeta) -> Result<Self> { ... } fn from_meta(item: &Meta) -> Result<Self> { ... } fn from_word() -> Result<Self> { ... } fn from_list(items: &[NestedMeta]) -> Result<Self> { ... } fn from_value(value: &Lit) -> Result<Self> { ... } fn from_char(value: char) -> Result<Self> { ... } fn from_string(value: &str) -> Result<Self> { ... } fn from_bool(value: bool) -> Result<Self> { ... } }
Create an instance from an item in an attribute declaration.
Implementing FromMeta
- 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: &NestedMeta) -> Result<Self>
fn from_meta(item: &Meta) -> Result<Self>
Create an instance from a syn::Meta
by dispatching to the format-appropriate
trait function. This generally should not be overridden by implementers.
fn from_word() -> Result<Self>
Create an instance from the presence of the word in the attribute with no additional options specified.
fn from_list(items: &[NestedMeta]) -> Result<Self>
Create an instance from a list of nested meta items.
fn from_value(value: &Lit) -> Result<Self>
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>
Create an instance from a char literal in a value position.
fn from_string(value: &str) -> Result<Self>
Create an instance from a string literal in a value position.
fn from_bool(value: bool) -> Result<Self>
Create an instance from a bool literal in a value position.
Implementations on Foreign Types
impl FromMeta for ()
[src]
fn from_word() -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for bool
[src]
fn from_word() -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
impl FromMeta for AtomicBool
[src]
fn from_meta(mi: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for String
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for u8
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for u16
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for u32
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for u64
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for usize
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for i8
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for i16
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for i32
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for i64
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for isize
[src]
fn from_string(s: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for Ident
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for Path
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for Meta
[src]
fn from_meta(value: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for WhereClause
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for Vec<WherePredicate>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl FromMeta for RenameRule
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for Option<T>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for Box<T>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for Result<T, Meta>
[src]
Parses the meta-item, and in case of error preserves a copy of the input for later analysis.
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for Rc<T>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for Arc<T>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<T: FromMeta> FromMeta for RefCell<T>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_list(items: &[NestedMeta]) -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
impl<V: FromMeta> FromMeta for HashMap<String, V>
[src]
fn from_list(nested: &[NestedMeta]) -> Result<Self>
[src]
fn from_nested_meta(item: &NestedMeta) -> Result<Self>
[src]
fn from_meta(item: &Meta) -> Result<Self>
[src]
fn from_word() -> Result<Self>
[src]
fn from_value(value: &Lit) -> Result<Self>
[src]
fn from_char(value: char) -> Result<Self>
[src]
fn from_string(value: &str) -> Result<Self>
[src]
fn from_bool(value: bool) -> Result<Self>
[src]
Implementors
impl<T: FromMeta> FromMeta for darling_core::error::Result<T>
impl FromMeta for ForwardAttrs
impl FromMeta for Shape
impl FromMeta for DataShape
impl FromMeta for IdentList
impl FromMeta for Ignored
impl<T: FromMeta> FromMeta for Override<T>
impl<T: FromMeta> FromMeta for WithOriginal<T, Meta>
impl FromMeta for Flag