Crates.io | compose_spec_macros |
lib.rs | compose_spec_macros |
version | 0.1.1 |
source | src |
created_at | 2024-04-05 20:08:00.936578 |
updated_at | 2024-10-16 12:38:59.539469 |
description | Procedural macros for use in the compose_spec crate |
homepage | |
repository | https://github.com/k9withabone/compose_spec_rs |
max_upload_size | |
id | 1197711 |
size | 109,951 |
compose_spec
is a Rust library crate for (de)serializing from/to the Compose specification.
compose_spec
strives for:
PathBuf
and Duration
.services
, network_mode
and networks
are combined into network_config
.build
and ports
).See the documentation for more details.
use compose_spec::{Compose, Service, service::Image};
let yaml = "\
services:
caddy:
image: docker.io/library/caddy:latest
ports:
- 8000:80
- 8443:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy-data:/data
volumes:
caddy-data:
";
// Deserialize `Compose`
let compose: Compose = serde_yaml::from_str(yaml)?;
// Serialize `Compose`
let value = serde_yaml::to_value(&compose)?;
// Get the `Image` of the "caddy" service
let caddy: Option<&Service> = compose.services.get("caddy");
let image: &Option<Image> = &caddy.unwrap().image;
let image: &Image = image.as_ref().unwrap();
assert_eq!(image, "docker.io/library/caddy:latest");
assert_eq!(image.name(), "docker.io/library/caddy");
assert_eq!(image.tag(), Some("latest"));
The minimum version of the Rust compiler compose_spec
can currently compile with is 1.70, which is tested in CI.
Increasing the MSRV is not considered to be a breaking change.
Contributions, suggestions, and/or comments are appreciated! Feel free to create an issue, discussion, or pull request. Generally, it is preferable to start a discussion for a feature request or open an issue for reporting a bug before submitting changes with a pull request.
compose_spec
is composed of two packages set up in a Cargo workspace. The root package, compose_spec
, is the main library.
The other package, compose_spec_macros
, located in a directory of the same name, is a procedural macro library used in compose_spec
. compose_spec_macros
is not designed to be used outside the compose_spec
library.
If you are submitting code changes in a pull request and would like to run the CI jobs locally, use the following commands:
cargo fmt --check --all
cargo clippy --workspace --tests
cargo test --workspace -- --include-ignored
cargo doc --workspace --document-private-items
rustup toolchain install nightly
.cargo docs-rs
typos
cargo msrv verify
rustup toolchain install nightly
.cargo minimal-versions check --workspace
cargo minimal-versions test --workspace
cargo semver-checks
All source code for compose_spec
is licensed under the Mozilla Public License v2.0.
View the LICENSE file for more information.
The Compose specification itself is licensed under the Apache License v2.0. See that project's LICENSE file for more information.