Skip to main content

ForgeQuery

Trait ForgeQuery 

Source
pub trait ForgeQuery:
    Send
    + Sync
    + 'static {
    type Args: DeserializeOwned + Serialize + Send + Sync;
    type Output: Serialize + Send;

    // Required methods
    fn info() -> FunctionInfo;
    fn execute(
        ctx: &QueryContext,
        args: Self::Args,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>;
}
Expand description

A query function (read-only, cacheable, subscribable).

Queries:

  • Can only read from the database
  • Are automatically cached based on arguments
  • Can be subscribed to for real-time updates
  • Should be deterministic (same inputs → same outputs)
  • Should not have side effects

Required Associated Types§

Source

type Args: DeserializeOwned + Serialize + Send + Sync

The input arguments type.

Source

type Output: Serialize + Send

The output type.

Required Methods§

Source

fn info() -> FunctionInfo

Function metadata.

Source

fn execute( ctx: &QueryContext, args: Self::Args, ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + '_>>

Execute the query.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§