Skip to main content

AttrDef

Struct AttrDef 

Source
pub struct AttrDef { /* private fields */ }
Expand description

A public framework attribute.

Implementations§

Source§

impl AttrDef

Source

pub const fn name(&self) -> &'static str

The attribute name without its android: prefix.

Source

pub const fn id(&self) -> ResourceId

Source

pub fn format(&self) -> AttrFormat

The accepted formats; AttrFormat::ANY when undeclared.

Source

pub fn accepts(&self, value: &Value) -> bool

Whether value has a format this attribute accepts, as aapt2 would have typed it. References, @null, @empty, and values of types this crate does not interpret are resolved at runtime, so they are always accepted.

use apk::android::attr;
use apk::res::Value;

assert!(attr::HAS_CODE.accepts(&Value::Bool(false)));
assert!(!attr::HAS_CODE.accepts(&Value::String("false".into())));
assert!(attr::SCREEN_ORIENTATION.accepts(&Value::Int(0)));
Source

pub const fn symbols(&self) -> &'static [Symbol]

The enum or flag values this attribute defines.

Source

pub fn symbol(&self, name: &str) -> Option<u32>

The value of the enum or flag named name.

Source

pub fn enum_name(&self, value: u32) -> Option<&'static str>

The name of the enum value value.

Source

pub fn flag_names(&self, value: u32) -> Option<Vec<&'static str>>

Names the flags set in value, if value is exactly a union of them.

Source§

impl AttrDef

Source

pub fn parse(&self, text: &str) -> Result<Value, XmlError>

Types text by the formats this attribute accepts, as aapt2 does:

use apk::android::attr;
use apk::res::Value;

assert_eq!(attr::SCREEN_ORIENTATION.parse("landscape")?, Value::Int(0));
assert_eq!(attr::CONFIG_CHANGES.parse("orientation|screenSize")?, Value::Hex(0x480));
assert_eq!(attr::EXPORTED.parse("true")?, Value::Bool(true));
assert!(attr::EXPORTED.parse("yes").is_err());

Trait Implementations§

Source§

impl Clone for AttrDef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for AttrDef

Source§

impl Debug for AttrDef

Source§

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

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

impl Display for AttrDef

Source§

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

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

impl Eq for AttrDef

Source§

impl From<&AttrDef> for AttrName

Source§

fn from(def: &AttrDef) -> Self

Converts to this type from the input type.
Source§

impl Hash for AttrDef

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AttrDef

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AttrDef

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomError for T
where T: Display + Debug + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Send + Sync + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync + 'static)

Source§

fn as_box_any(self: Box<T>) -> Box<dyn Any + Send + Sync>

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.