rship keeps its workspace permanently lean at 7 crates while already shipping 10 built-in providers. Adding a new storage backend never requires adding a workspace crate—implement one feature-gated module inside rship-backends, wire config/factory once in rship, and register a thin ProviderAdapter in rship-cli.
Core Invariants Every Provider Must Uphold#
- Low Memory (
<= 64 MiBRSS): Stream directory entries over boundedmpsc::channel(256)(EntryStream), stream upload bodies directly without collecting large files into RAM, and returnDataSource::RemoteRangeReadablefromopen_readfor zero-RAM cloud-to-cloud relays. - Crash-Resumable Uploads: Declare exact geometry in
Capabilities(UploadTopology::SequentialorParallelParts,ChunkAlignment,single_shot_max_bytes,default_chunk_size) and implementbegin_upload,query_upload,upload_chunk,finish_upload,abort_upload, andreconcile_operation. - Reuse Shared Infrastructure:
rship_transport::HttpTransport(split H2/H1,--proxy,--ca-cert, stall watchdog, CUBIC limiter)rship_transport::oauth(PkceSession,OAuth2TokenManager,FileTokenStore)rship_backends::common(rx_to_entry_stream,StrictBodyStream,ExactDownloadStream,common::http,common::crc,common::google_sa,common::xml)rship_core::rclone_ini(INI parser + AES-256-CTR obscured secret decryption)
4-Step Recipe to Add Provider foo#
Step 1: Add Module crates/rship-backends/src/foo/#
crates/rship-backends/
├── Cargo.toml # Feature `foo = [...]` + optional deps + `[[test]]`
├── src/
│ ├── lib.rs # `#[cfg(feature = "foo")] pub mod foo;`
│ └── foo/
│ ├── mod.rs # Re-export FooBackend, FooConfig, parse_rclone_foo_conf
│ ├── config.rs # Typed config & chunk alignment constants
│ ├── auth.rs # Thin wrapper over `rship_transport::oauth` (if OAuth2)
│ ├── backend.rs # `impl StorageBackend for FooBackend`
│ └── rclone_import.rs # Optional `rclone.conf` parser
└── tests/
└── foo_conformance.rs # `required-features = ["foo"]`Step 2: Implement StorageBackend & Run the Universal Conformance Suite#
Implement mandatory identity, namespace (stat, list_stream, mkdir, delete, compute_hash, open_read), and resumable upload methods—plus optional high-value overrides (delete_batch, can_server_side_copy_from/server_side_copy, about, rename).
Then verify all 9 universal invariants in foo_conformance.rs with a single call:
rship_core::conformance::run_backend_conformance(Arc::new(backend), clock).await;# Fast isolated test loop during development
cargo test -p rship-backends --no-default-features --features fooStep 3: Wire Type, Config & Factory Once in rship-core & crates/rship#
Because rship-cli's CliRuntime wraps RshipClient directly, wiring your provider once in rship-core and crates/rship unlocks both the Rust SDK (RshipClient) and rship-cli simultaneously:
crates/rship-core/src/types.rs: AddBackendKind::Fooplus itsas_str()andparse()arms.crates/rship/Cargo.toml: Add featurefoo = ["rship-backends/foo", "http"](omit"http"for non-HTTP backends) and add"foo"toall-backends.crates/rship/src/config.rs: Add#[must_use] #[non_exhaustive] pub struct FooRemoteConfigwith::new(...)/ fluentwith_*builders, redactedDebug,RemoteConfig::Foo(Box<FooRemoteConfig>),From<FooRemoteConfig> for RemoteConfig, and wirekind()+visit_secrets/visit_secrets_mut(single source of truth for redaction and OS Keyring lifecycle).crates/rship/src/lib.rs&prelude.rs: Re-exportFooRemoteConfig.crates/rship/src/factory.rs: HandleRemoteConfig::Fooinbuild_remote_backend,target_needs_transport(if non-HTTP), andimport_rclone_conf*if applicable.
Step 4: Register CLI Auth & Lifecycle in rship-cli#
crates/rship-cli/Cargo.toml: Addbackend-foo = ["rship/foo", "rship-backends/foo"]to features andall-backends.crates/rship-cli/src/cli.rs: AddFooAuthArgsandAuthAction::Foo(FooAuthArgs).crates/rship-cli/src/ops/config_ops.rs: Add summary, description, ordering, and aliases forRemoteConfig::Foo.crates/rship-cli/src/providers/foo.rs+providers/mod.rs: ImplementProviderAdapter(kind,rclone_type, optionalcleanup_secretsfor sidecar tokens,abort_gc_operationviaabort_gc_for_remotes,export_bundle,import_bundle) +handle_auth, register&foo::FooAdapterinregistered_providers(), and dispatchAuthAction::Fooindispatch_provider_auth. Secret redaction and keyring migration work automatically viaRemoteConfig::visit_secrets*.
Once registered, every command (copy, sync, move, bisync, check, hashsum, cat, rcat, about, tree, gc, config, auth export|import|keyring-migrate, and crypt overlay remotes) works automatically.
# Verify full workspace, minimal SDK, and isolated CLI builds
cargo clippy --workspace --all-targets -- -D warnings
cargo check -p rship --no-default-features --features foo
cargo clippy -p rship-cli --no-default-features --features backend-local,backend-foo -- -D warnings
cargo test --workspace