dove-core 0.1.0

The shared library behind dove — client-side-encrypted, expiring file sharing from a cloud you own.
Documentation
//! The transfer seam: the operations every backend (self-hosted S3 today, a
//! future hosted cloud backend later) must implement. The CLI and the Dove
//! desktop app drive shares through this trait instead of talking to S3
//! directly, so a new backend plugs in without either caller changing.

use crate::error::Result;
use crate::progress::Progress;
use std::path::PathBuf;
use std::time::Duration;

/// What to share: a resolved local path plus the policy for the resulting link.
pub struct ShareRequest {
    pub path: PathBuf,
    pub expires: Duration,
    pub encrypt: bool,
    pub downloads: Option<u32>,
    pub pin: Option<String>,
    pub from: Option<String>,
    pub message: Option<String>,
}

/// The result of a successful share: the link to hand out, plus what got recorded.
pub struct Share {
    pub id: String,
    pub link: String,
    pub size: u64,
    pub expires_at: u64,
}

/// What to fetch: a share link (and, if the gate demands one, a pin).
pub struct GetRequest {
    pub url: String,
    pub out: Option<PathBuf>,
    pub pin: Option<String>,
}

/// The result of a successful fetch: where the file landed, and the trust
/// metadata the sender attached (if any) — their name and a short message,
/// decrypted from the gate's `/meta` blob with the fragment secret.
pub struct Fetched {
    pub path: PathBuf,
    pub from: Option<String>,
    pub message: Option<String>,
}

/// One entry in `dove ls` — enough to identify and describe a live share
/// without re-fetching its contents.
pub struct ShareInfo {
    pub id: String,
    pub filename: Option<String>,
    pub expires_at: u64,
}

/// Backend health/config summary for `dove status` — an ordered list of
/// label/value pairs so callers can render it without knowing the backend kind.
pub struct BackendStatus {
    pub summary: Vec<(String, String)>,
}

/// The seam every backend implements: share a file, fetch one, list and
/// revoke what this machine has shared, and report backend status. No
/// terminal I/O here — progress is reported through `&dyn Progress`, and
/// results are returned for the caller to render.
pub trait Transfer {
    fn share(&self, req: ShareRequest, progress: &dyn Progress) -> Result<Share>;
    fn get(&self, req: GetRequest, progress: &dyn Progress) -> Result<Fetched>;
    fn list(&self) -> Result<Vec<ShareInfo>>;
    fn revoke(&self, id: &str) -> Result<()>;
    fn status(&self) -> Result<BackendStatus>;
}