wire/answer/document_bytes.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! A stored object as bytes, window by window, and a Markdown version
7//! exported as one HTML file (`crates/wire/spec/Answer/DocumentBytes.lean`
8//! §8-80, §8-81).
9//!
10//! Bytes travel on the same socket as every other answer, so a device on
11//! the remote door reaches them through its sealed session (wire D18).
12
13use documents::Span;
14use kernel::B3Hash;
15use serde::{Deserialize, Serialize};
16
17/// The most bytes one `Bytes` answer carries.
18pub const BYTES_WINDOW_MAX: u64 = 1 << 20;
19
20/// One window of a stored object's bytes.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
23pub struct BytesAnswer {
24 pub version: B3Hash,
25 /// The stretch answered; the next request starts at its end.
26 pub span: Span,
27 /// The whole object's length.
28 pub size: u64,
29 /// The stretch's bytes, in the standard base64 alphabet with padding.
30 pub base64: String,
31}
32
33/// A Markdown version written as one HTML file that stands alone.
34#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
35#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
36pub struct ExportAnswer {
37 pub version: B3Hash,
38 pub html: String,
39}