pub struct Variables { /* private fields */ }Expand description
Ordered set of channel variables with FreeSWITCH escaping.
Values containing commas are escaped with \,, single quotes with \',
and values with spaces are wrapped in single quotes.
§Serde format
Default scope serializes as a flat JSON map:
{"key": "value", ...}. Non-default scopes serialize as
{"scope": "Enterprise", "vars": {"key": "value"}}.
Deserialization accepts both formats; a flat map implies Default scope.
Implementations§
Source§impl Variables
impl Variables
Sourcepub fn new(vars_type: VariablesType) -> Self
pub fn new(vars_type: VariablesType) -> Self
Create an empty variable set with the given scope.
Sourcepub fn with_vars(
vars_type: VariablesType,
vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn with_vars( vars_type: VariablesType, vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Create from an existing set of key-value pairs.
Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
Insert or overwrite a variable.
Sourcepub fn remove(&mut self, key: &str) -> Option<String>
pub fn remove(&mut self, key: &str) -> Option<String>
Remove a variable by name, returning its value if it existed.
Sourcepub fn scope(&self) -> VariablesType
pub fn scope(&self) -> VariablesType
Variable scope (Enterprise, Default, or Channel).
Sourcepub fn set_scope(&mut self, scope: VariablesType)
pub fn set_scope(&mut self, scope: VariablesType)
Change the variable scope.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Iterate over key-value pairs in insertion order.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut String)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut String)>
Mutable iterator over key-value pairs in insertion order.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut String>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut String>
Mutable iterator over values in insertion order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Variables
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Variables
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Variables
impl StructuralPartialEq for Variables
Auto Trait Implementations§
impl Freeze for Variables
impl RefUnwindSafe for Variables
impl Send for Variables
impl Sync for Variables
impl Unpin for Variables
impl UnsafeUnpin for Variables
impl UnwindSafe for Variables
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.