Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[workspace]
resolver = "3"
members = [".", "crates/api", "crates/cfg", "crates/cli", "crates/zonedata"]
members = [
".",
"crates/cli",

"crates/api",
"crates/cfg",
"crates/policy-file",
"crates/zonedata",
]
default-members = [".", "crates/cli"]

[workspace.package]
Expand Down Expand Up @@ -91,6 +99,9 @@ version = "0.2.15"
[workspace.dependencies.serde]
version = "1.0"

[workspace.dependencies.serde_with]
version = "3"

# 'toml' is a Serde-compatible library for working with TOML documents.
#
# It is used throughout the Rust ecosystem and is maintained accordingly.
Expand Down Expand Up @@ -119,9 +130,10 @@ daemonbase = { version = "0.1.5", features = ["tokio"] }
serde = { workspace = true, features = ["derive", "rc"] }
rayon = "1.10.0"
serde_json = "1.0"
serde_with = "3"
url = { version = "2.4", features = ["serde"] }

serde_with.workspace = true

# `futures` provides some async functionality not available in `std` yet. It's
# quite a big crate, and we only need a subset of the functionality, so we only
# import the `-util` subcrate.
Expand Down Expand Up @@ -183,6 +195,7 @@ idna_adapter = { version = "=1.0.0" }

cascade-api = { path = "crates/api" }
cascade-cfg = { path = "crates/cfg" }
cascade-policy-file = { path = "crates/policy-file" }
cascade-zonedata = { path = "crates/zonedata" }

# 'clap' is used for top-level configuration of the command-line interface (most
Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ path = "../api"
# The CLI delegates to Clap to handle basic concerns like argument parsing.
[dependencies.clap]
workspace = true
default-features = true
features = ["cargo", "derive", "env", "wrap_help"]

# The CLI uses 'jiff' to process timestamps and durations, and to print them in
Expand Down
50 changes: 50 additions & 0 deletions crates/policy-file/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "cascade-policy-file"
description = "Cascade's policy files."

authors.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
license.workspace = true

version.workspace = true
rust-version.workspace = true
edition.workspace = true

readme = "README.md"


# --- Dependencies -------------------------------------------------------------

[dependencies]

# The user can specify filesystem paths to Cascade. Paths need to be represented
# in a platform-independent way, ruling out 'std::path::Path'. 'camino' offers
# UTF-8-only paths that match this requirement.
[dependencies.camino]
workspace = true
features = ["serde1"]

[dependencies.domain]
workspace = true
features = ["tsig", "serde"]

# 'foldhash' offers fast, non-cryptographic hash tables.
[dependencies.foldhash]
workspace = true

# 'jiff' is a general-purpose time library.
[dependencies.jiff]
workspace = true

# 'serde' and 'toml' are used for parsing TOML configuration files.
[dependencies.serde]
workspace = true
features = ["derive"]
[dependencies.toml]
workspace = true

# 'serde-with' provides helpers for 'serde'.
[dependencies.serde_with]
workspace = true
File renamed without changes.
32 changes: 32 additions & 0 deletions crates/policy-file/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Definitions for Cascade policy files.

use serde::{Deserialize, Serialize};

//--- Versions

pub mod v1;

//--- Helpers

mod datetime;
Comment thread
ximon18 marked this conversation as resolved.
Outdated

//----------- VersionedSpec ----------------------------------------------------

/// A versioned policy file specification.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", tag = "version")]
pub enum VersionedSpec {
/// The version 1 format.
V1(v1::Spec),
}

// TODO(idea @bal-e): Define a version-independent policy file specification?
// - Would be called `Spec`.
// - Initially reuse definitions from `v1`.
// - `Spec` could be converted to and from `VersionedSpec` explicitly.
// - Convert from any version, always build the latest version.
// - Maybe also provide conversions to and from every individual version.
// - Conversions _to_ individual versions might need to be fallible.
// - Unclear if conversion to the latest version can/should be fallible.
// - It would let users write policy files without locking themselves to a
// particular version.
Loading
Loading