|
1 |
| -use std::{fmt::Display, ops::Deref, str::FromStr, sync::LazyLock}; |
| 1 | +use std::{ |
| 2 | + fmt::{Debug, Display}, |
| 3 | + ops::Deref, |
| 4 | + str::FromStr, |
| 5 | + sync::LazyLock, |
| 6 | +}; |
2 | 7 |
|
3 | 8 | use regex::Regex;
|
4 | 9 | use snafu::{ensure, ResultExt, Snafu};
|
@@ -56,12 +61,21 @@ pub enum KeyError {
|
56 | 61 | /// values.
|
57 | 62 | ///
|
58 | 63 | /// [k8s-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
|
59 |
| -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] |
| 64 | +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] |
60 | 65 | pub struct Key {
|
61 | 66 | prefix: Option<KeyPrefix>,
|
62 | 67 | name: KeyName,
|
63 | 68 | }
|
64 | 69 |
|
| 70 | +impl Debug for Key { |
| 71 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 72 | + if let Some(prefix) = &self.prefix { |
| 73 | + write!(f, "{:?}/", prefix)?; |
| 74 | + } |
| 75 | + write!(f, "{:?}", self.name) |
| 76 | + } |
| 77 | +} |
| 78 | + |
65 | 79 | impl FromStr for Key {
|
66 | 80 | type Err = KeyError;
|
67 | 81 |
|
@@ -203,9 +217,15 @@ pub enum KeyPrefixError {
|
203 | 217 | /// [`Deref`], which enables read-only access to the inner value (a [`String`]).
|
204 | 218 | /// It, however, does not implement [`DerefMut`](std::ops::DerefMut) which would
|
205 | 219 | /// enable unvalidated mutable access to inner values.
|
206 |
| -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] |
| 220 | +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] |
207 | 221 | pub struct KeyPrefix(String);
|
208 | 222 |
|
| 223 | +impl Debug for KeyPrefix { |
| 224 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 225 | + write!(f, "{:?}", self.0) |
| 226 | + } |
| 227 | +} |
| 228 | + |
209 | 229 | impl FromStr for KeyPrefix {
|
210 | 230 | type Err = KeyPrefixError;
|
211 | 231 |
|
@@ -285,9 +305,15 @@ pub enum KeyNameError {
|
285 | 305 | /// which enables read-only access to the inner value (a [`String`]). It,
|
286 | 306 | /// however, does not implement [`DerefMut`](std::ops::DerefMut) which would
|
287 | 307 | /// enable unvalidated mutable access to inner values.
|
288 |
| -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] |
| 308 | +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] |
289 | 309 | pub struct KeyName(String);
|
290 | 310 |
|
| 311 | +impl Debug for KeyName { |
| 312 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 313 | + write!(f, "{:?}", self.0) |
| 314 | + } |
| 315 | +} |
| 316 | + |
291 | 317 | impl FromStr for KeyName {
|
292 | 318 | type Err = KeyNameError;
|
293 | 319 |
|
|
0 commit comments