Skip to content

Commit

Permalink
remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hafihaf123 committed Feb 10, 2025
1 parent de26de8 commit 51afbf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 51 deletions.
31 changes: 3 additions & 28 deletions rama-http/src/headers/util/value_string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::headers::Error;
use bytes::Bytes;
use http::header::HeaderValue;
use std::fmt::{Display, Formatter};
use std::{
Expand All @@ -17,29 +15,6 @@ pub struct HeaderValueString {
}

impl HeaderValueString {
pub(crate) fn from_val(val: &HeaderValue) -> Result<Self, Error> {
if val.to_str().is_ok() {
Ok(HeaderValueString { value: val.clone() })
} else {
Err(Error::invalid())
}
}

pub(crate) fn from_string(src: String) -> Option<Self> {
// A valid `str` (the argument)...
let bytes = Bytes::from(src);
HeaderValue::from_maybe_shared(bytes)
.ok()
.map(|value| HeaderValueString { value })
}

pub(crate) fn from_static(src: &'static str) -> HeaderValueString {
// A valid `str` (the argument)...
HeaderValueString {
value: HeaderValue::from_static(src),
}
}

pub(crate) fn as_str(&self) -> &str {
// HeaderValueString is only created from HeaderValues
// that have validated they are also UTF-8 strings.
Expand All @@ -48,13 +23,13 @@ impl HeaderValueString {
}

impl fmt::Debug for HeaderValueString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}
}

impl fmt::Display for HeaderValueString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl Display for HeaderValueString {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
fmt::Display::fmt(self.as_str(), f)
}
}
Expand Down
24 changes: 1 addition & 23 deletions rama-http/src/headers/x_robots_tag_components/custom_rule.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::headers::util::value_string::{FromStrError, HeaderValueString};
use crate::headers::util::value_string::HeaderValueString;

#[derive(Clone, Debug, Eq, PartialEq)]
pub(super) struct CustomRule {
Expand All @@ -7,28 +7,6 @@ pub(super) struct CustomRule {
}

impl CustomRule {
pub(super) fn new(key: &str) -> Result<Self, FromStrError> {
Ok(Self {
key: key.parse()?,
value: None,
})
}

pub(super) fn with_value(key: &str, value: &str) -> Result<Self, FromStrError> {
Ok(Self {
key: key.parse()?,
value: Some(value.parse()?),
})
}

pub(super) fn key(&self) -> &HeaderValueString {
&self.key
}

pub(super) fn value(&self) -> Option<&HeaderValueString> {
self.value.as_ref()
}

pub(super) fn as_tuple(&self) -> (&HeaderValueString, &Option<HeaderValueString>) {
(&self.key, &self.value)
}
Expand Down

0 comments on commit 51afbf8

Please sign in to comment.