Struct edgedb_tokio::state::GlobalsModifier

source ·
pub struct GlobalsModifier<'a> { /* private fields */ }
Expand description

Utility object used to modify globals

This object is passed to Fn closure and GlobalsDelta::apply.

Implementations§

source§

impl GlobalsModifier<'_>

source

pub fn set<T: QueryArg>(&mut self, key: &str, value: T)

Set global variable to a value

If key doesn’t contain module name (:: to be more specific) then the variable name is resolved using current module. Otherwise, modules are resolved using aliases if any. Note: modules are resolved at method call time. This means that a sequence like this:

let conn = conn
    .with_globals_fn(|m| m.set("var1", "value1"))
    .with_default_module(Some("another_module"))
    .with_globals_fn(|m| m.set("var1", "value2"));

Will set var1 in default and in another_module to different values.

§Panics

This methods panics if value cannot be converted into dynamically typed Value (QueryArg::to_value() method returns error). To avoid this panic use either native EdgeDB types (e.g. edgedb_protocol::model::Datetime instead of std::time::SystemTime or call to_value manually before passing to set.

source

pub fn unset(&mut self, key: &str)

Unset the global variable

In most cases this will effectively set the variable to a default value.

To set variable to the actual empty value use set("name", Value::Nothing).

Note: same namespacing rules like for set are applied here.

Trait Implementations§

source§

impl<'a> Debug for GlobalsModifier<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for GlobalsModifier<'a>

§

impl<'a> RefUnwindSafe for GlobalsModifier<'a>

§

impl<'a> Send for GlobalsModifier<'a>

§

impl<'a> Sync for GlobalsModifier<'a>

§

impl<'a> Unpin for GlobalsModifier<'a>

§

impl<'a> !UnwindSafe for GlobalsModifier<'a>

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

§

type Output = T

Should always be Self
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.
source§

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

source§

fn vzip(self) -> V