crabfit/api/adaptors
D. Scott Boggs 7239578f95
Some checks are pending
API Checks / clippy (push) Waiting to run
Deploy API / Deploy to Fly.io (push) Waiting to run
WIP add password file
2025-05-05 07:18:21 -04:00
..
datastore Change how cleanup trait fn works using a date cutoff 2023-05-16 01:37:01 +10:00
memory Change how cleanup trait fn works using a date cutoff 2023-05-16 01:37:01 +10:00
sql WIP add password file 2025-05-05 07:18:21 -04:00
README.md Change how cleanup trait fn works using a date cutoff 2023-05-16 01:37:01 +10:00

Crab Fit Storage Adaptors

This directory contains sub-crates that connect Crab Fit to a database of some sort. For a list of available adaptors, see the api readme.

Adding an adaptor

The suggested flow is copying an existing adaptor, such as memory, and altering the code to work with your chosen database.

Note, you will need to have the following crates as dependencies in your adaptor:

  • common
    Includes a trait for implementing your adaptor, as well as structs your adaptor needs to return.
  • async-trait
    Required because the trait from common uses async functions, make sure you include #[async_trait] above your trait implementation.
  • chrono
    Required to deal with dates in the common structs and trait function signatures.

Once you've created the adaptor, you'll need to make sure it's included as a dependency in the root Cargo.toml, and add a feature flag with the same name. Make sure you also document the new adaptor in the api readme.

Finally, add a new version of the create_adaptor function in the adaptors.rs file that will only compile if the specific feature flag you added is set. Don't forget to add a not version of the feature to the default memory adaptor function at the bottom of the file.

FAQ

Why is it spelt "adaptor" and not "adapter"?

The maintainer lives in Australia, where it's usually spelt "adaptor" 😎