Struct deltachat::param::Params

source ·
pub struct Params {
    inner: BTreeMap<Param, String>,
}
Expand description

An object for handling key=value parameter lists.

The structure is serialized by calling to_string() on it.

Only for library-internal use.

Fields§

§inner: BTreeMap<Param, String>

Implementations§

source§

impl Params

source

pub fn new() -> Self

Create new empty params.

source

pub fn get(&self, key: Param) -> Option<&str>

Get the value of the given key, return None if no value is set.

source

pub fn exists(&self, key: Param) -> bool

Check if the given key is set.

source

pub fn set(&mut self, key: Param, value: impl ToString) -> &mut Self

Set the given key to the passed in value.

source

pub fn remove(&mut self, key: Param) -> &mut Self

Removes the given key, if it exists.

source

pub fn set_optional( &mut self, key: Param, value: Option<impl ToString> ) -> &mut Self

Sets the given key from an optional value. Removes the key if the value is None.

source

pub fn is_empty(&self) -> bool

Check if there are any values in this.

source

pub fn len(&self) -> usize

Returns how many key-value pairs are set.

source

pub fn get_int(&self, key: Param) -> Option<i32>

Get the given parameter and parse as i32.

source

pub fn get_i64(&self, key: Param) -> Option<i64>

Get the given parameter and parse as i64.

source

pub fn get_bool(&self, key: Param) -> Option<bool>

Get the given parameter and parse as bool.

source

pub fn get_cmd(&self) -> SystemMessage

Get the parameter behind Param::Cmd interpreted as SystemMessage.

source

pub fn set_cmd(&mut self, value: SystemMessage)

Set the parameter behind Param::Cmd.

source

pub fn get_float(&self, key: Param) -> Option<f64>

Get the given parameter and parse as f64.

source

pub fn get_file<'a>( &self, key: Param, context: &'a Context ) -> Result<Option<ParamsFile<'a>>>

Gets the given parameter and parse as ParamsFile.

See also Params::get_blob and Params::get_path which may be more convenient.

source

pub async fn get_blob<'a>( &self, key: Param, context: &'a Context, create: bool ) -> Result<Option<BlobObject<'a>>>

Gets the parameter and returns a BlobObject for it.

This parses the parameter value as a ParamsFile and than tries to return a BlobObject for that file. If the file is not yet a valid blob, one will be created by copying the file only if create is set to true, otherwise an error is returned.

Note that in the ParamsFile::FsPath case the blob can be created without copying if the path already refers to a valid blob. If so a BlobObject will be returned regardless of the create argument.

source

pub fn get_path(&self, key: Param, context: &Context) -> Result<Option<PathBuf>>

Gets the parameter and returns a PathBuf for it.

This parses the parameter value as a ParamsFile and returns a PathBuf to the file.

source

pub fn get_msg_id(&self) -> Option<MsgId>

source

pub fn set_int(&mut self, key: Param, value: i32) -> &mut Self

Set the given parameter to the passed in i32.

source

pub fn set_i64(&mut self, key: Param, value: i64) -> &mut Self

Set the given parameter to the passed in i64.

source

pub fn set_float(&mut self, key: Param, value: f64) -> &mut Self

Set the given parameter to the passed in f64 .

source§

impl Params

source

pub(crate) fn update_timestamp( &mut self, scope: Param, new_timestamp: i64 ) -> Result<bool>

Updates a param’s timestamp in memory, if reasonable. Returns true if the caller shall update the settings belonging to the scope.

Trait Implementations§

source§

impl Clone for Params

source§

fn clone(&self) -> Params

Returns a copy 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 Params

source§

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

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

impl Default for Params

source§

fn default() -> Params

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

impl<'de> Deserialize<'de> for Params

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Params

source§

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

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

impl FromStr for Params

source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parse a raw string to Param.

Silently ignore unknown keys: they may come from a downgrade (when a shortly new version adds a key) or from an upgrade (when a key is dropped but was used in the past)

§

type Err = Error

The associated error which can be returned from parsing.
source§

impl PartialEq for Params

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Params

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Params

source§

impl StructuralEq for Params

source§

impl StructuralPartialEq for Params

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
§

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

§

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

§

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

§

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
§

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

§

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

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

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

§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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§

default 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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

impl<T> RpcMessage for T
where T: Debug + Serialize + DeserializeOwned + Send + Sync + Unpin + 'static,