zoe_wire_protocol/
blob.rs1use crate::BlobId;
2use serde::{Deserialize, Serialize};
3
4#[tarpc::service]
6pub trait BlobService {
7 async fn health_check() -> BlobResult<BlobHealth>;
9
10 async fn upload(data: Vec<u8>) -> BlobResult<BlobId>;
12
13 async fn download(hash: BlobId) -> BlobResult<Option<Vec<u8>>>;
15
16 async fn get_info(hash: BlobId) -> BlobResult<Option<BlobInfo>>;
18
19 async fn check_blobs(hashes: Vec<BlobId>) -> BlobResult<Vec<bool>>;
25}
26
27pub type BlobResult<T> = Result<T, BlobError>;
29
30#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32pub struct BlobHealth {
33 pub status: String,
34 pub total_blobs: u64,
35 pub total_size_bytes: u64,
36}
37
38#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
40pub struct BlobInfo {
41 pub hash: BlobId,
42 pub size_bytes: u64,
43 pub created_at: String,
44}
45
46#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, thiserror::Error)]
48pub enum BlobError {
49 #[error("Blob not found: {hash}")]
50 NotFound { hash: BlobId },
51
52 #[error("Invalid blob hash: {hash}")]
53 InvalidHash { hash: BlobId },
54
55 #[error("Storage error: {message}")]
56 StorageError { message: String },
57
58 #[error("Serialization error: {message}")]
59 SerializationError { message: String },
60
61 #[error("IO error: {message}")]
62 IoError { message: String },
63
64 #[error("Internal server error: {message}")]
65 InternalError { message: String },
66}