Skip to main content

State

Trait State 

Source
pub trait State: MaybeSync {
    type Db: Db;
    type SchemaCache<'a>: Deref<Target = SchemaCache> + MaybeSend + MaybeSync
       where Self: 'a;

    // Required methods
    fn db(&self) -> &Self::Db;
    fn schema_cache(
        &self,
    ) -> impl Future<Output = Self::SchemaCache<'_>> + MaybeSend;
    fn config(&self) -> &AppConfig;
    fn jwt_config(&self) -> &JwtConfig;
    fn jwt_cache(&self) -> Option<&JwtCache>;

    // Provided methods
    fn default_schema(&self) -> &str { ... }
    fn schemas(&self) -> &[String] { ... }
}
Expand description

Everything the pipeline needs from its host.

The server’s AppState is one, over a sqlx pool. A host with no sqlx – a Cloudflare Worker – brings its own, over its own Db. The pipeline is generic over this, so nothing on the native path goes through a vtable.

Required Associated Types§

Source

type Db: Db

The database requests run on.

Source

type SchemaCache<'a>: Deref<Target = SchemaCache> + MaybeSend + MaybeSync where Self: 'a

A borrow of the schema cache, held for as long as a request needs it.

Required Methods§

Source

fn db(&self) -> &Self::Db

The database requests run on.

Source

fn schema_cache( &self, ) -> impl Future<Output = Self::SchemaCache<'_>> + MaybeSend

The schema cache.

Source

fn config(&self) -> &AppConfig

Configuration.

Source

fn jwt_config(&self) -> &JwtConfig

How tokens are verified.

Source

fn jwt_cache(&self) -> Option<&JwtCache>

The cache of verified tokens, where one is configured.

Provided Methods§

Source

fn default_schema(&self) -> &str

The schema a request names when it names none.

Source

fn schemas(&self) -> &[String]

The schemas the API exposes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§