pub trait DataContext<'a> {
    // Required methods
    fn data<D: Any + Send + Sync>(&self) -> Result<&'a D>;
    fn data_unchecked<D: Any + Send + Sync>(&self) -> &'a D;
    fn data_opt<D: Any + Send + Sync>(&self) -> Option<&'a D>;
}
Expand description

Data related functions of the context.

Required Methods§

source

fn data<D: Any + Send + Sync>(&self) -> Result<&'a D>

Gets the global data defined in the Context or Schema.

If both Schema and Query have the same data type, the data in the Query is obtained.

Errors

Returns a Error if the specified type data does not exist.

source

fn data_unchecked<D: Any + Send + Sync>(&self) -> &'a D

Gets the global data defined in the Context or Schema.

Panics

It will panic if the specified data type does not exist.

source

fn data_opt<D: Any + Send + Sync>(&self) -> Option<&'a D>

Gets the global data defined in the Context or Schema or None if the specified type data does not exist.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a> DataContext<'a> for ExtensionContext<'a>

source§

impl<'a, T> DataContext<'a> for ContextBase<'a, T>