1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! The [`BlobStore`] trait -- async blob storage for artifact payloads.
//!
//! A blob store holds the *bytes* of an artifact. Its metadata (name, size,
//! hash, owning step) lives in the run store, which is the source of truth:
//! a blob with no metadata row is never served.
use Future;
use Pin;
use Bytes;
use Stream;
use crateArtifactError;
/// Boxed future returned by [`BlobStore`] methods -- keeps the trait object safe.
pub type BlobFuture<'a, T> = ;
/// Stream of bytes, used for both upload and download.
///
/// Artifacts are never buffered whole in memory: an upload is consumed as it
/// arrives and a download is produced as it is read.
pub type ByteStream = ;
/// What a [`BlobStore::put`] recorded about the bytes it just wrote.
///
/// # Examples
///
/// ```
/// use ironflow_artifacts::blob_store::BlobDigest;
///
/// let digest = BlobDigest {
/// size_bytes: 4,
/// sha256: "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08".to_string(),
/// };
/// assert_eq!(digest.size_bytes, 4);
/// ```
/// Async blob storage for artifact payloads.
///
/// All methods return a [`BlobFuture`] so the store can be used as
/// `Arc<dyn BlobStore>`.
///
/// # Examples
///
/// ```no_run
/// use std::sync::Arc;
///
/// use ironflow_artifacts::blob_store::BlobStore;
/// use ironflow_artifacts::local::LocalBlobStore;
/// use ironflow_artifacts::stream_from_bytes;
///
/// # async fn example() -> Result<(), ironflow_artifacts::error::ArtifactError> {
/// let store: Arc<dyn BlobStore> = Arc::new(LocalBlobStore::new("/var/lib/ironflow/artifacts"));
///
/// let digest = store
/// .put("artifacts/run/step/id", stream_from_bytes(b"hello".to_vec()))
/// .await?;
/// assert_eq!(digest.size_bytes, 5);
/// # Ok(())
/// # }
/// ```