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::support::events::VoidObserver;
17use crate::support::void_context::VoidContext;
18use crate::transport::ipfs::IpfsBackend;
19
20pub use export::*;
21pub use push::*;
22pub use sync::*;
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum CloneMode {
26    Depth1,
27    Full,
28    Lazy,
29}
30
31pub struct CloneOptions {
32    pub ctx: VoidContext,
33    pub commit_cid: String,
34    pub backend: IpfsBackend,
35    pub timeout: Duration,
36    pub mode: CloneMode,
37    /// Optional observer for progress events
38    pub observer: Option<Arc<dyn VoidObserver>>,
39}
40
41#[derive(Debug, Clone)]
42pub struct CloneResult {
43    pub commit_cid: String,
44    pub metadata_cid: String,
45    pub repo_secret: RepoSecret,
46    pub shards_fetched: usize,
47    pub shards_total: usize,
48    pub mode: CloneMode,
49    /// CID of the repo manifest (collab commits), if present and restored
50    pub repo_manifest_cid: Option<String>,
51}
52
53pub struct PullOptions {
54    pub ctx: VoidContext,
55    pub commit_cid: String,
56    pub backend: IpfsBackend,
57    pub timeout: Duration,
58    pub mode: CloneMode,
59    /// Optional observer for progress events
60    pub observer: Option<Arc<dyn VoidObserver>>,
61}
62
63#[derive(Debug, Clone)]
64pub struct PullResult {
65    pub commit_cid: String,
66    pub metadata_cid: String,
67    pub shards_fetched: usize,
68    pub shards_total: usize,
69    pub mode: CloneMode,
70    pub commits_fetched: usize,
71    /// CID of the repo manifest (collab commits), if present and restored
72    pub repo_manifest_cid: Option<String>,
73}
74
75pub struct PushOptions {
76    pub ctx: VoidContext,
77    pub commit_cid: Option<String>,
78    pub backend: IpfsBackend,
79    pub timeout: Duration,
80    pub pin: bool,
81    /// Backend name for push-marker tracking (e.g. "local", "aws")
82    pub backend_name: String,
83    /// Ignore push marker and push all objects from HEAD to root
84    pub full: bool,
85    /// Force push: skip missing objects instead of failing.
86    /// Still fails on integrity errors (corrupt data).
87    pub force: bool,
88    /// Optional observer for progress events
89    pub observer: Option<Arc<dyn VoidObserver>>,
90}
91
92/// An object that was skipped during force push.
93#[derive(Debug, Clone)]
94pub struct SkippedObject {
95    /// CID of the skipped object.
96    pub cid: String,
97    /// Reason why the object was skipped.
98    pub reason: String,
99    /// CID of the commit that referenced this object.
100    pub referenced_by: String,
101}
102
103#[derive(Debug, Clone)]
104pub struct PushResult {
105    pub commit_cid: String,
106    pub objects_pushed: usize,
107    pub pinned: usize,
108    pub commits_pushed: usize,
109    /// Objects that were skipped during force push (empty if not force mode).
110    pub skipped_objects: Vec<SkippedObject>,
111}
112
113/// Options for exporting a commit to a CAR file.
114#[derive(Debug, Clone)]
115pub struct ExportCarOptions {
116    pub ctx: VoidContext,
117    pub commit_cid: Option<String>,
118}
119
120/// Result of CAR export.
121#[derive(Debug, Clone)]
122pub struct ExportCarResult {
123    pub commit_cid: String,
124    pub car_path: PathBuf,
125    pub blocks_exported: usize,
126    pub car_size: u64,
127}