Skip to main content

AdapterFactory

Trait AdapterFactory 

Source
pub trait AdapterFactory: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn open(&self, config: Value) -> Result<Box<dyn Adapter>, AdapterError>;
    fn probe_default(&self, env: &Env) -> Option<Value>;
    fn serialize(
        &self,
        session: &SessionWithMessages,
        fidelity: RestoreFidelity,
    ) -> Result<Vec<RestoredFile>, AdapterError>;
}
Expand description

Stateless face of an adapter type: how the registry knows about it without instantiating it. One implementation per known format, registered in registry.

Required Methods§

Source

fn name(&self) -> &'static str

Stable short name. Used as the [sources.<name>] config key, the pond sync <name> positional arg, and the Session.source_agent value emitted by the corresponding adapter.

Source

fn open(&self, config: Value) -> Result<Box<dyn Adapter>, AdapterError>

Open a configured adapter from a JSON-shaped config blob. The shape is owned by each factory: filesystem adapters expect { "path": "..." }, API-backed adapters expect { "endpoint": "...", "auth_token": "..." }, etc. The seam doesn’t know or care. A factory rejects a bad blob with AdapterErrorKind::Config.

Source

fn probe_default(&self, env: &Env) -> Option<Value>

Probe the user’s environment for a default config. Returns the JSON blob that would go into [sources.<name>] if the picker writes it back. Filesystem adapters check their canonical install path under env.home; adapters with no auto-discovery rule (e.g. API adapters that need explicit creds) return None.

Source

fn serialize( &self, session: &SessionWithMessages, fidelity: RestoreFidelity, ) -> Result<Vec<RestoredFile>, AdapterError>

Restore one canonical session into this adapter’s native file layout.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§