Skip to main content

void_core/pipeline/remote/
mod.rs

1//! Remote operations: clone, pull, push via IPFS.
2//!
3//! Push uses marker-based range optimization: tracks the last successfully pushed
4//! commit per backend. On push, walks from HEAD to the marker, collecting all object
5//! CIDs across the unpushed range so every intermediate commit's objects are uploaded.
6
7mod export;
8mod push;
9mod sync;
10
11use std::path::PathBuf;
12use std::sync::Arc;
13use std::time::Duration;
14
15use crate::crypto::RepoSecret;
16use crate::store::RemoteStore;
17use crate::support::events::VoidObserver;
18use crate::support::void_context::VoidContext;
19use crate::transport::ipfs::IpfsBackend;
20
21pub use export::*;
22pub use push::*;
23pub use sync::*;
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum CloneMode {
27    Depth1,
28    Full,
29    Lazy,
30    /// Fetch commit + metadata only. No shards, no working tree files.
31    /// Files are fetched on demand via `void read`.
32    Virtual,
33}
34
35pub struct CloneOptions {
36    pub ctx: VoidContext,
37    pub commit_cid: String,
38    pub backend: IpfsBackend,
39    pub timeout: Duration,
40    pub mode: CloneMode,
41    /// Optional observer for progress events
42    pub observer: Option<Arc<dyn VoidObserver>>,
43    /// Optional injected remote store (daemon). If None, creates IpfsStore from backend.
44    pub remote: Option<Arc<dyn RemoteStore>>,
45}
46
47#[derive(Debug, Clone)]
48pub struct CloneResult {
49    pub commit_cid: String,
50    pub metadata_cid: String,
51    pub repo_secret: RepoSecret,
52    pub shards_fetched: usize,
53    pub shards_total: usize,
54    pub mode: CloneMode,
55    /// CID of the repo manifest (collab commits), if present and restored
56    pub repo_manifest_cid: Option<String>,
57}
58
59pub struct PullOptions {
60    pub ctx: VoidContext,
61    pub commit_cid: String,
62    pub backend: IpfsBackend,
63    pub timeout: Duration,
64    pub mode: CloneMode,
65    /// Optional observer for progress events
66    pub observer: Option<Arc<dyn VoidObserver>>,
67    /// Optional injected remote store (daemon). If None, creates IpfsStore from backend.
68    pub remote: Option<Arc<dyn RemoteStore>>,
69}
70
71#[derive(Debug, Clone)]
72pub struct PullResult {
73    pub commit_cid: String,
74    pub metadata_cid: String,
75    pub shards_fetched: usize,
76    pub shards_total: usize,
77    pub mode: CloneMode,
78    pub commits_fetched: usize,
79    /// CID of the repo manifest (collab commits), if present and restored
80    pub repo_manifest_cid: Option<String>,
81}
82
83pub struct PushOptions {
84    pub ctx: VoidContext,
85    pub commit_cid: Option<String>,
86    pub backend: IpfsBackend,
87    pub timeout: Duration,
88    pub pin: bool,
89    /// Backend name for push-marker tracking (e.g. "local", "aws")
90    pub backend_name: String,
91    /// Ignore push marker and push all objects from HEAD to root
92    pub full: bool,
93    /// Force push: skip missing objects instead of failing.
94    /// Still fails on integrity errors (corrupt data).
95    pub force: bool,
96    /// Optional observer for progress events
97    pub observer: Option<Arc<dyn VoidObserver>>,
98    /// Optional injected remote store (daemon). If None, creates IpfsStore from backend.
99    pub remote: Option<Arc<dyn RemoteStore>>,
100}
101
102/// An object that was skipped during force push.
103#[derive(Debug, Clone)]
104pub struct SkippedObject {
105    /// CID of the skipped object.
106    pub cid: String,
107    /// Reason why the object was skipped.
108    pub reason: String,
109    /// CID of the commit that referenced this object.
110    pub referenced_by: String,
111}
112
113#[derive(Debug, Clone)]
114pub struct PushResult {
115    pub commit_cid: String,
116    pub objects_pushed: usize,
117    pub pinned: usize,
118    pub commits_pushed: usize,
119    /// Objects that were skipped during force push (empty if not force mode).
120    pub skipped_objects: Vec<SkippedObject>,
121}
122
123/// Options for exporting a commit to a CAR file.
124#[derive(Debug, Clone)]
125pub struct ExportCarOptions {
126    pub ctx: VoidContext,
127    pub commit_cid: Option<String>,
128}
129
130/// Result of CAR export.
131#[derive(Debug, Clone)]
132pub struct ExportCarResult {
133    pub commit_cid: String,
134    pub car_path: PathBuf,
135    pub blocks_exported: usize,
136    pub car_size: u64,
137}