caravel_export_poc

Crates.iocaravel_export_poc
lib.rscaravel_export_poc
version0.1.2
sourcesrc
created_at2024-03-12 20:15:33.800881
updated_at2024-03-13 00:09:04.550201
descriptionCaravel Module Wrapper
homepage
repositoryhttps://github.com/pkmollman/caravel_export_poc
max_upload_size
id1170990
size41,664
(pkmollman)

documentation

README

Caravel Export usage

cargo new --lib your_caravel_lib
cargo add caravel_export_poc
cargo add anyhow
cargo add serde --features derive
cargo add serde_json

Make sure your Cargo.toml has the below entry in the [lib] section.

crate-type = ["cdylib"]

Put the following proc macros on the struct you'd like to expose to Caravel in your library.

#[caravel_resource]
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct File {
    pub path: PathBuf,
    pub state: FileState,
    pub owner: Option<String>,
    pub group: Option<String>,
}

Then you must implement validate and apply function on your resourse with the following signature.

impl File {
    fn validate(&self) -> Result<()> {
        Ok(())
    }
    fn apply(&self) -> Result<()> {
       Ok(())
    }
}

When you compile the lib and use it with Caravel, the resulting .so,.dylib,.dll should be named the same as your resource. Example for dummy library above: File.so

Then you can drop it in the caravel_modules directory of your Caravel Project!

Commit count: 0

cargo fmt