stellation_bridge/links/
mod.rs

1//! The links used to resolve routines.
2//!
3//! For server-sided links, a new link should be created for each connection.
4
5use async_trait::async_trait;
6
7use crate::routines::{BridgedMutation, BridgedQuery, MutationResult, QueryResult};
8use crate::BridgeResult;
9mod fetch_link;
10mod local_link;
11mod phantom_link;
12
13pub use fetch_link::FetchLink;
14pub use local_link::LocalLink;
15pub use phantom_link::PhantomLink;
16
17/// Common methods across all links.
18#[async_trait(?Send)]
19pub trait Link: PartialEq + Clone {
20    /// Resolves a Query.
21    async fn resolve_query<T>(&self, input: &T::Input) -> QueryResult<T>
22    where
23        T: 'static + BridgedQuery;
24
25    /// Resolves a Mutation.
26    async fn resolve_mutation<T>(&self, input: &T::Input) -> MutationResult<T>
27    where
28        T: 'static + BridgedMutation;
29
30    /// Resolve a routine with encoded input.
31    ///
32    /// Returns `BridgeError` when a malformed input is provided.
33    async fn resolve_encoded(&self, input_buf: &[u8]) -> BridgeResult<Vec<u8>>;
34}