dove_core/request.rs
1//! Status types for a `dove request` — the PIN-gated ask for someone else to
2//! upload a file to you. `share` run backwards: the link's creator is the
3//! eventual receiver. `dove-core` reports these; the CLI and the desktop app
4//! render them without needing to know how the gate encodes state on the wire.
5//! See [`docs/REQUEST.md`](../docs/REQUEST.md) for the full design.
6
7use std::time::Duration;
8
9/// What to create: the ask (description), optional trust metadata (who's
10/// asking, why), an optional PIN the gate checks before handing out an
11/// upload slot, how long the link stays live, and the upload budget.
12/// `SelfHosted::create_request` consumes this; the CLI (and later the desktop
13/// app) build it from user input.
14#[derive(Debug, Clone)]
15pub struct CreateRequest {
16 pub description: String,
17 pub from: Option<String>,
18 pub message: Option<String>,
19 pub pin: Option<String>,
20 pub expires: Duration,
21 pub uploads: u32,
22}
23
24/// Where a request stands: nobody's uploaded yet, something arrived, or the
25/// one attempt the gate allowed came back bad.
26#[derive(Debug, Clone)]
27pub enum RequestStatus {
28 Waiting,
29 Received { name: String, size: u64 },
30 Failed { reason: String },
31}
32
33/// One request, enough to identify, describe, and show the state of — what
34/// `dove requests` lists and `dove requests get` looks up.
35#[derive(Debug, Clone)]
36pub struct RequestInfo {
37 pub id: String,
38 pub description: String,
39 pub status: RequestStatus,
40}
41
42/// The result of creating a request: the id (for the local ledger) and the
43/// link to hand to whoever you're asking to upload.
44#[derive(Debug, Clone)]
45pub struct NewRequest {
46 pub id: String,
47 pub link: String,
48}