Compare commits

..

No commits in common. "main" and "v0.1.2" have entirely different histories.

7 changed files with 47 additions and 77 deletions

View file

@ -5,12 +5,13 @@ on:
jobs: jobs:
checks: checks:
runs-on: nix runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: https://codeberg.org/icewind/attic-action@v1 - uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with: with:
name: link name: ci
instance: https://cache.icewind.link instance: https://cache.icewind.me
authToken: "${{ secrets.ATTIC_TOKEN }}" authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix flake check --keep-going - run: nix flake check --keep-going

6
Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = 3
[[package]] [[package]]
name = "rfc7239" name = "rfc7239"
version = "0.1.3" version = "0.1.2"
dependencies = [ dependencies = [
"uncased", "uncased",
] ]
@ -20,6 +20,6 @@ dependencies = [
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.5" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

View file

@ -1,17 +1,13 @@
[package] [package]
name = "rfc7239" name = "rfc7239"
version = "0.1.3" version = "0.1.2"
authors = ["Robin Appelman <robin@icewind.nl>"] authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2018" edition = "2018"
description = "Parser for rfc7239 formatted Forwarded headers" description = "Parser for rfc7239 formatted Forwarded headers"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://codeberg.org/icewind/rfc7239" repository = "https://github.com/icewind1991/rfc7239"
documentation = "https://docs.rs/rfc7239" documentation = "https://docs.rs/rfc7239"
rust-version = "1.56.1" rust-version = "1.56.1"
[dependencies] [dependencies]
uncased = "0.9.10" uncased = "0.9.10"
[features]
std = []
default = ["std"]

View file

@ -18,13 +18,4 @@ for node_result in parse(header_value) {
} }
``` ```
## `no_std`
This crate can be used in a `no_std` environment by disabling the default `std`
feature.
The only impact disabling this feature has is using `core::error::Error` and
`core::net::IpAddr` instead of the `std` variants and increasing the msrv to
1.81.
[rfc7239]: https://tools.ietf.org/html/rfc7239 [rfc7239]: https://tools.ietf.org/html/rfc7239

44
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"crane": { "crane": {
"locked": { "locked": {
"lastModified": 1742394900, "lastModified": 1730060262,
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", "narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", "rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -22,11 +22,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1747659009, "lastModified": 1732697024,
"narHash": "sha256-3FFAthqh4rWKTClF+WgM+9CmMDlnfWcPdd3hGBFVNHc=", "narHash": "sha256-GcLauDQQI4xO4vy3e2QxPneR86FsJ1ubAbFDlTyEZ9s=",
"owner": "nix-community", "owner": "nix-community",
"repo": "flakelight", "repo": "flakelight",
"rev": "93d72adbe0b022791b0faadfb31cb6e98c37f0ad", "rev": "1af817b5987e78b7a260dff6d62793716b98d794",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -44,31 +44,31 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1747928985, "lastModified": 1732306573,
"narHash": "sha256-OGJvoEbcclL566m9PCq+SdOQ9vJzLfVCOkww9L/uZT8=", "narHash": "sha256-wE12kIIE0qb9V9y0JiVm5RsRrMNX+KeeMwkzwefdHhY=",
"ref": "refs/heads/main", "owner": "icewind1991",
"rev": "742b8596357b53bf437d504a87455f46edba8be2", "repo": "mill-scale",
"revCount": 46, "rev": "8b4cbf174a9728d7e58bbfde5b5a6685dcbf1015",
"type": "git", "type": "github"
"url": "https://codeberg.org/icewind/mill-scale.git"
}, },
"original": { "original": {
"type": "git", "owner": "icewind1991",
"url": "https://codeberg.org/icewind/mill-scale.git" "repo": "mill-scale",
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1747862697, "lastModified": 1732632634,
"narHash": "sha256-U4HaNZ1W26cbOVm0Eb5OdGSnfQVWQKbLSPrSSa78KC0=", "narHash": "sha256-+G7n/ZD635aN0sEXQLynU7pWMd3PKDM7yBIXvYmjABQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2baa12ff69913392faf0ace833bc54bba297ea95", "rev": "6f6076c37180ea3a916f84928cf3a714c5207a30",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-24.11", "ref": "nixos-24.05",
"type": "indirect" "type": "indirect"
} }
}, },
@ -88,11 +88,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1742697269, "lastModified": 1731897198,
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=", "narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316", "rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,12 +1,12 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-24.11"; nixpkgs.url = "nixpkgs/nixos-24.05";
flakelight = { flakelight = {
url = "github:nix-community/flakelight"; url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
mill-scale = { mill-scale = {
url = "git+https://codeberg.org/icewind/mill-scale.git"; url = "github:icewind1991/mill-scale";
inputs.flakelight.follows = "flakelight"; inputs.flakelight.follows = "flakelight";
}; };
}; };

View file

@ -1,12 +1,10 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! Parser for [rfc7239] formatted `Forwarded` headers. //! Parser for [rfc7239] formatted `Forwarded` headers.
//! //!
//! ## Usage //! ## Usage
//! //!
//! ``` //! ```
//! use rfc7239::parse; //! use rfc7239::parse;
//! # use core::error::Error; //! # use std::error::Error;
//! //!
//! # fn main() -> Result<(), Box<dyn Error>> { //! # fn main() -> Result<(), Box<dyn Error>> {
//! // get the header value from your favorite http server library //! // get the header value from your favorite http server library
@ -23,26 +21,10 @@
//! ``` //! ```
//! //!
//! [rfc7239]: https://tools.ietf.org/html/rfc7239 //! [rfc7239]: https://tools.ietf.org/html/rfc7239
use std::error::Error;
#[cfg(all(test, not(feature = "std")))] use std::fmt::{Debug, Display, Formatter};
extern crate std; use std::net::IpAddr;
#[cfg(all(test, not(feature = "std")))] use std::str::FromStr;
use std::{format, vec, vec::Vec};
#[cfg(not(feature = "std"))]
use core::{
error::Error,
fmt::{Debug, Display, Formatter},
net::IpAddr,
str::FromStr,
};
#[cfg(feature = "std")]
use std::{
error::Error,
fmt::{Debug, Display, Formatter},
net::IpAddr,
str::FromStr,
};
use uncased::UncasedStr; use uncased::UncasedStr;
#[derive(Debug)] #[derive(Debug)]
@ -54,7 +36,7 @@ pub enum RfcError {
} }
impl Display for RfcError { impl Display for RfcError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let str = match self { let str = match self {
RfcError::InvalidIdentifier => "Invalid node identifier", RfcError::InvalidIdentifier => "Invalid node identifier",
RfcError::InvalidPort => "Invalid node port", RfcError::InvalidPort => "Invalid node port",
@ -132,8 +114,8 @@ impl<'a> Forwarded<'a> {
} }
} }
impl Display for Forwarded<'_> { impl<'a> Display for Forwarded<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut needs_delim = false; let mut needs_delim = false;
if let Some(ident) = &self.forwarded_for { if let Some(ident) = &self.forwarded_for {
if ident.display_needs_quote() { if ident.display_needs_quote() {
@ -265,8 +247,8 @@ impl<'a> NodeIdentifier<'a> {
} }
} }
impl Display for NodeIdentifier<'_> { impl<'a> Display for NodeIdentifier<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.port { match self.port {
Some(port) => write!(f, "{}:{}", self.name, port), Some(port) => write!(f, "{}:{}", self.name, port),
None => write!(f, "{}", self.name), None => write!(f, "{}", self.name),
@ -393,8 +375,8 @@ impl<'a> NodeName<'a> {
} }
} }
impl Display for NodeName<'_> { impl<'a> Display for NodeName<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self { match self {
NodeName::Ip(IpAddr::V4(ip)) => write!(f, "{}", ip), NodeName::Ip(IpAddr::V4(ip)) => write!(f, "{}", ip),
NodeName::Ip(IpAddr::V6(ip)) => write!(f, "[{}]", ip), NodeName::Ip(IpAddr::V6(ip)) => write!(f, "[{}]", ip),