# RFS Client Rhai Examples This folder contains Rhai examples that use the SAL RFS client wrappers registered by `sal::rhai::register(&mut engine)` and executed by the `herodo` binary. ## Prerequisites - Build with the client feature enabled (any of these): - `--features rfsclient` - `--features clients` - `--features all` - Environment variables: - `RFS_BASE_URL` (e.g., `https://rfs.example.com`) - `RFS_USER` and `RFS_PASS` ## Quick start Run the auth + upload + download example: ```bash RFS_BASE_URL=https://rfs.example.com \ RFS_USER=your_user \ RFS_PASS=your_pass \ cargo run -p herodo --features clients -- examples/rfsclient/auth_and_upload.rhai ``` ## What the example does - Creates the RFS client: `rfs_create_client(BASE_URL, USER, PASS, TIMEOUT)` - Health check: `rfs_health_check()` - Authenticates: `rfs_authenticate()` - Uploads a file: `rfs_upload_file(local_path)` -> file hash - Downloads it back: `rfs_download_file(file_id_or_hash, dest_path)` See `examples/rfsclient/auth_and_upload.rhai` for details. ## Using the Rust client directly (optional) If you want to use the Rust API (without Rhai), depend on `sal-rfs-client` and see: - `packages/clients/rfsclient/src/client.rs` (`RfsClient`) - `packages/clients/rfsclient/src/types.rs` (config and option types) ## Troubleshooting - Missing functions in Rhai: ensure features include `rfsclient` (or `clients`/`all`). - Auth failures: verify `RFS_USER`/`RFS_PASS` and that the server requires/authenticates credentials. - Connection errors: verify `RFS_BASE_URL` is reachable from your machine.