Skip to content

Commit

Permalink
Implement From<Cow<'_, str>> and From<&Path> for TagValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mleonhard committed Jan 11, 2024
1 parent 2f61335 commit d8fed10
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["web", "http", "server", "async", "threaded"]
license = "MIT OR Apache-2.0"
name = "servlin"
repository = "https://github.com/mleonhard/servlin"
version = "0.4.2"
version = "0.4.3"

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Functions Expressions Impls Traits Methods Dependency
See [rust-webserver-comparison.md](https://github.com/mleonhard/servlin/blob/main/rust-webserver-comparison.md).

# Changelog
- v0.4.3 - Implement `From<Cow<'_, str>>` and `From<&Path>` for `TagValue`.
- v0.4.2 - Implement `Seek` for `BodyReader`.
- v0.4.1
- Add `Request::opt_json`.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
//! See [rust-webserver-comparison.md](https://github.com/mleonhard/servlin/blob/main/rust-webserver-comparison.md).
//!
//! # Changelog
//! - v0.4.3 - Implement `From<Cow<'_, str>>` and `From<&Path>` for `TagValue`.
//! - v0.4.2 - Implement `Seek` for `BodyReader`.
//! - v0.4.1
//! - Add `Request::opt_json`.
Expand Down
12 changes: 12 additions & 0 deletions src/log/tag_value.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::borrow::Cow;
use std::fmt::{Debug, Display, Formatter};
use std::path::Path;

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TagValue {
Expand Down Expand Up @@ -60,6 +62,16 @@ impl From<String> for TagValue {
Self::String(value)
}
}
impl From<Cow<'_, str>> for TagValue {
fn from(value: Cow<'_, str>) -> Self {
Self::String(value.into_owned())
}
}
impl From<&Path> for TagValue {
fn from(value: &Path) -> Self {
Self::String(value.to_string_lossy().to_string())
}
}
impl From<bool> for TagValue {
fn from(value: bool) -> Self {
Self::Bool(value)
Expand Down

0 comments on commit d8fed10

Please sign in to comment.