Runtime

Trait Runtime 

Source
pub trait Runtime {
    type Error: ToString;

    // Required methods
    fn date<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_args<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn query<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        graphql: &'life2 GraphqlRequest,
        headers: HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn read_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn prepare_output_directory<'life0, 'life1, 'async_trait>(
        &'life0 self,
        output: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        output: &'life1 str,
        file: &'life2 str,
        contents: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

The trait that all tools that use this library must implement.

A runtime provides all of the “outside world” interaction that the library can use to do its job.

This allows docql to be implemented as a native binary and as a wasm-module.

Required Associated Types§

Source

type Error: ToString

The error type that the runtime returns.

Required Methods§

Source

fn date<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current date as an ISO-8601 date

Source

fn get_args<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the arguments passed on the command (not including the binary name)

Note that standard argv includes the binary name. This method expects the binary name to be stripped from the front. This makes implementing the WASM binary easier.

Source

fn query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 str, graphql: &'life2 GraphqlRequest, headers: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run the given GraphQL request (the introspection query) against the URL, returning the JSON response.

Source

fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a file from the filesystem.

Used when rendering documentation based on an already downloaded schema.

Source

fn prepare_output_directory<'life0, 'life1, 'async_trait>( &'life0 self, output: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepare the output directory.

The runtime can use this to create the directory, etc.

Source

fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, output: &'life1 str, file: &'life2 str, contents: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Write contents to the given file.

Implementors§