pub struct AttrDef { /* private fields */ }Expand description
A public framework attribute.
Implementations§
Source§impl AttrDef
impl AttrDef
pub const fn id(&self) -> ResourceId
Sourcepub fn format(&self) -> AttrFormat
pub fn format(&self) -> AttrFormat
The accepted formats; AttrFormat::ANY when undeclared.
Sourcepub fn accepts(&self, value: &Value) -> bool
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§impl AttrDef
impl AttrDef
Sourcepub fn parse(&self, text: &str) -> Result<Value, XmlError>
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§
impl Copy for AttrDef
impl Eq for AttrDef
impl StructuralPartialEq for AttrDef
Auto Trait Implementations§
impl Freeze for AttrDef
impl RefUnwindSafe for AttrDef
impl Send for AttrDef
impl Sync for AttrDef
impl Unpin for AttrDef
impl UnsafeUnpin for AttrDef
impl UnwindSafe for AttrDef
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomError for T
impl<T> CustomError for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.