shuttle_service

Trait ResourceInputBuilder

Source
pub trait ResourceInputBuilder: Default {
    type Input: Serialize + DeserializeOwned;
    type Output: Serialize + DeserializeOwned;

    // Required method
    fn build<'life0, 'async_trait>(
        self,
        factory: &'life0 ResourceFactory,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Input, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Allows implementing plugins for the Shuttle main function.

§Creating your own Shuttle plugin

You can add your own implementation of this trait along with IntoResource to customize the input type R that gets into the Shuttle main function on an existing resource.

You can also make your own plugin, for example to generalise the connection logic to a third-party service. One example of this is shuttle-qdrant.

Please refer to shuttle-examples/custom-resource for examples of how to create a custom resource. For more advanced provisioning of custom resources, please get in touch and detail your use case. We’ll be interested to see what you want to provision and how to do it on your behalf on the fly.

Required Associated Types§

Source

type Input: Serialize + DeserializeOwned

The input for requesting this resource.

If the input is a shuttle_common::resource::ProvisionResourceRequest, then the resource will be provisioned and the ResourceInputBuilder::Output will be a shuttle_common::resource::ShuttleResourceOutput<T> with the resource’s associated output type.

Source

type Output: Serialize + DeserializeOwned

The output from provisioning this resource.

For custom resources that don’t provision anything from Shuttle, this should be the same type as ResourceInputBuilder::Input.

This type must implement IntoResource for the desired final resource type R.

Required Methods§

Source

fn build<'life0, 'async_trait>( self, factory: &'life0 ResourceFactory, ) -> Pin<Box<dyn Future<Output = Result<Self::Input, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Construct this resource config. The ResourceFactory provides access to secrets and metadata.

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§