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