gantry_protocol/
stream.rs

1//! # Gantry streaming protocol
2//!
3//! This module contains data types and traits for use with Gantry's module streaming
4//! functionality. Gantry separates the streaming of a module's raw bytes from the management
5//! of a module's metadata. The following operations are available for streaming:
6//! * `stream_put` - Send the raw bytes for a module to Gantry, corresponding to a specific public key+revision pair
7//! * `stream_get` - Retrieve the raw bytes for a module to Gantry, corresponding to a specific public key+revision pair
8
9// Requests to initiate transfers
10pub static SUBJECT_STREAM_DOWNLOAD: &str = "gantry.stream.get";
11pub static SUBJECT_STREAM_UPLOAD: &str = "gantry.stream.put";
12
13// Topics on which actual transfers occur
14pub static SUBJECT_STREAM_DOWNLOAD_PREFIX: &str = "gantry.stream.download.";
15pub static SUBJECT_STREAM_UPLOAD_PREFIX: &str = "gantry.stream.upload.";
16
17/// A request to download a file from Gantry
18#[derive(Debug, PartialEq, Deserialize, Serialize)]
19pub struct DownloadRequest {
20    pub actor: String,
21    pub revision: u32,
22}
23
24/// A request to upload a file to Gantry
25#[derive(Debug, PartialEq, Deserialize, Serialize)]
26pub struct UploadRequest {
27    pub actor: String,
28    pub total_bytes: u64,
29    pub chunk_size: u64,
30    pub total_chunks: u64,
31}
32
33#[derive(Debug, PartialEq, Deserialize, Serialize)]
34pub struct TransferAck {
35    pub success: bool,
36    pub actor: String,
37    pub total_bytes: u64,
38    pub chunk_size: u64,
39    pub total_chunks: u64,
40}
41
42/// Acknowledgement of a single chunk
43#[derive(Debug, PartialEq, Deserialize, Serialize)]
44pub struct ChunkAck {
45    pub success: bool,
46    pub sequence_no: u64,
47    pub bytes_sent: u64,
48}
49
50/// A single chunk of a file
51#[derive(Debug, PartialEq, Deserialize, Serialize)]
52pub struct FileChunk {
53    pub sequence_no: u64,
54    pub actor: String,
55    pub total_bytes: u64,
56    pub chunk_size: u64,
57    pub total_chunks: u64,
58    pub chunk_bytes: Vec<u8>,
59}