warg_api/v1/
mod.rs

1//! Types representing v1 of the Warg REST API.
2
3pub mod content;
4pub mod fetch;
5pub mod ledger;
6pub mod monitor;
7pub mod package;
8pub mod paths;
9pub mod proof;
10
11use serde::{Deserialize, Serialize};
12
13/// The HTTP request and response header name that specifies the registry domain whose data is the
14/// subject of the request. This header is only expected to be used if referring to a different
15/// registry than the host registry.
16pub const REGISTRY_HEADER_NAME: &str = "warg-registry";
17/// The HTTP response header name that specifies that the client should
18/// try another registry
19pub const REGISTRY_HINT_HEADER_NAME: &str = "warg-registry-hint";
20
21/// Represents the supported kinds of content sources.
22#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
23#[serde(tag = "type", rename_all = "camelCase")]
24pub enum ContentSource {
25    /// The content can be retrieved with an HTTP GET.
26    #[serde(rename_all = "camelCase")]
27    HttpGet {
28        /// The URL of the content.
29        url: String,
30        /// Optional, server accepts for HTTP Range header.
31        #[serde(default, skip_serializing_if = "is_false", alias = "accept_ranges")]
32        accept_ranges: bool,
33        /// Optional, provides content size in bytes.
34        #[serde(skip_serializing_if = "Option::is_none")]
35        size: Option<u64>,
36    },
37}
38
39fn is_false(b: &bool) -> bool {
40    !b
41}