PersistableBundle

Struct PersistableBundle 

Source
pub struct PersistableBundle(/* private fields */);
Expand description

A mapping from string keys to values of various types.

Implementations§

Source§

impl PersistableBundle

Source

pub fn new() -> Self

Creates a new PersistableBundle.

Source

pub fn size(&self) -> usize

Returns the number of mappings in the bundle.

Source

pub fn remove(&mut self, key: &str) -> Result<bool, NulError>

Removes any entry with the given key.

Returns an error if the given key contains a NUL character, otherwise returns whether there was any entry to remove.

Source

pub fn insert_bool(&mut self, key: &str, value: bool) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_int(&mut self, key: &str, value: i32) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_long(&mut self, key: &str, value: i64) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_double(&mut self, key: &str, value: f64) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_string(&mut self, key: &str, value: &str) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key or value contains a NUL character.

Source

pub fn insert_bool_vec( &mut self, key: &str, value: &[bool], ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_int_vec( &mut self, key: &str, value: &[i32], ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_long_vec( &mut self, key: &str, value: &[i64], ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_double_vec( &mut self, key: &str, value: &[f64], ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_string_vec<'a, T: ToString + 'a>( &mut self, key: &str, value: impl IntoIterator<Item = &'a T>, ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn insert_persistable_bundle( &mut self, key: &str, value: &PersistableBundle, ) -> Result<(), NulError>

Inserts a key-value pair into the bundle.

If the key is already present then its value will be overwritten by the given value.

Returns an error if the key contains a NUL character.

Source

pub fn get_bool(&self, key: &str) -> Result<Option<bool>, NulError>

Gets the boolean value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_int(&self, key: &str) -> Result<Option<i32>, NulError>

Gets the i32 value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_long(&self, key: &str) -> Result<Option<i64>, NulError>

Gets the i64 value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_double(&self, key: &str) -> Result<Option<f64>, NulError>

Gets the f64 value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_string(&self, key: &str) -> Result<Option<String>, NulError>

Gets the string value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_bool_vec(&self, key: &str) -> Result<Option<Vec<bool>>, NulError>

Gets the boolean vector value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_int_vec(&self, key: &str) -> Result<Option<Vec<i32>>, NulError>

Gets the i32 vector value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_long_vec(&self, key: &str) -> Result<Option<Vec<i64>>, NulError>

Gets the i64 vector value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_double_vec(&self, key: &str) -> Result<Option<Vec<f64>>, NulError>

Gets the f64 vector value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_string_vec(&self, key: &str) -> Result<Option<Vec<String>>, NulError>

Gets the string vector value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn get_persistable_bundle( &self, key: &str, ) -> Result<Option<Self>, NulError>

Gets the PersistableBundle value associated with the given key.

Returns an error if the key contains a NUL character, or Ok(None) if the key doesn’t exist in the bundle.

Source

pub fn keys_for_type(&self, value_type: ValueType) -> Vec<String>

Gets all the keys associated with values of the given type.

Source

pub fn keys(&self) -> impl Iterator<Item = (String, ValueType)> + use<'_>

Returns an iterator over all keys in the bundle, along with the type of their associated value.

Trait Implementations§

Source§

impl Clone for PersistableBundle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PersistableBundle

Source§

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

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

impl Default for PersistableBundle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deserialize for PersistableBundle

Source§

type UninitType = Option<PersistableBundle>

Type for the uninitialized value of this type. Will be either Self if the type implements Default, Option<Self> otherwise.
Source§

fn uninit() -> Self::UninitType

Return an uninitialized or default-initialized value for this type.
Source§

fn from_init(value: Self) -> Self::UninitType

Convert an initialized value of type Self into Self::UninitType.
Source§

fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>

Deserialize an instance from the given crate::parcel::Parcel.
Source§

fn deserialize_from( &mut self, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Deserialize an instance from the given crate::parcel::Parcel onto the current object. This operation will overwrite the old value partially or completely, depending on how much data is available.
Source§

const ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _

Assert at compile-time that Self and Self::UninitType have the same size and alignment. This will either fail to compile or evaluate to true. The only two macros that work here are panic! and assert!, so we cannot use assert_eq!.
Source§

impl DeserializeArray for PersistableBundle

Source§

fn deserialize_array( parcel: &BorrowedParcel<'_>, ) -> Result<Option<Vec<Self>>, StatusCode>

Deserialize an array of type from the given parcel.
Source§

impl DeserializeOption for PersistableBundle

Source§

fn deserialize_option( parcel: &BorrowedParcel<'_>, ) -> Result<Option<Self>, StatusCode>

Deserialize an Option of this type from the given parcel.
Source§

fn deserialize_option_from( this: &mut Option<Self>, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Deserialize an Option of this type from the given parcel onto the current object. This operation will overwrite the current value partially or completely, depending on how much data is available.
Source§

impl Drop for PersistableBundle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for PersistableBundle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PersistableBundle

Source§

fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>

Serialize this instance into the given crate::parcel::Parcel.
Source§

impl SerializeArray for PersistableBundle

Source§

fn serialize_array( slice: &[Self], parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Serialize an array of this type into the given parcel.
Source§

impl SerializeOption for PersistableBundle

Source§

fn serialize_option( this: Option<&Self>, parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Serialize an Option of this type into the given parcel.
Source§

impl UnstructuredParcelable for PersistableBundle

Source§

fn write_to_parcel( &self, parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Internal serialization function for parcelables. Read more
Source§

fn from_parcel(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>

Internal deserialization function for parcelables. Read more
Source§

fn read_from_parcel( &mut self, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Internal deserialization function for parcelables. Read more
Source§

impl Send for PersistableBundle

Source§

impl Sync for PersistableBundle

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<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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

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

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

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

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

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

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.