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
//! Types representing v1 of the Warg REST API.
pub mod content;
pub mod fetch;
pub mod ledger;
pub mod monitor;
pub mod package;
pub mod paths;
pub mod proof;
use serde::{Deserialize, Serialize};
/// The HTTP request and response header name that specifies the registry domain whose data is the
/// subject of the request. This header is only expected to be used if referring to a different
/// registry than the host registry.
pub const REGISTRY_HEADER_NAME: &str = "warg-registry";
/// The HTTP response header name that specifies that the client should
/// try another registry
pub const REGISTRY_HINT_HEADER_NAME: &str = "warg-registry-hint";
/// Represents the supported kinds of content sources.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum ContentSource {
/// The content can be retrieved with an HTTP GET.
#[serde(rename_all = "camelCase")]
HttpGet {
/// The URL of the content.
url: String,
/// Optional, server accepts for HTTP Range header.
#[serde(default, skip_serializing_if = "is_false", alias = "accept_ranges")]
accept_ranges: bool,
/// Optional, provides content size in bytes.
#[serde(skip_serializing_if = "Option::is_none")]
size: Option<u64>,
},
}
fn is_false(b: &bool) -> bool {
!b
}