-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
707a209
commit f280156
Showing
6 changed files
with
102 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
use crate::headers::util::value_string::{FromStrError, HeaderValueString}; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct CustomRule { | ||
pub(super) struct CustomRule { | ||
key: HeaderValueString, | ||
value: Option<HeaderValueString>, | ||
} | ||
|
||
impl CustomRule { | ||
pub fn new(key: &str) -> Result<Self, FromStrError> { | ||
pub(super) fn new(key: &str) -> Result<Self, FromStrError> { | ||
Ok(Self { | ||
key: key.parse()?, | ||
value: None, | ||
}) | ||
} | ||
|
||
pub fn with_value(key: &str, value: &str) -> Result<Self, FromStrError> { | ||
pub(super) fn with_value(key: &str, value: &str) -> Result<Self, FromStrError> { | ||
Ok(Self { | ||
key: key.parse()?, | ||
value: Some(value.parse()?), | ||
}) | ||
} | ||
|
||
pub fn key(&self) -> &HeaderValueString { | ||
pub(super) fn key(&self) -> &HeaderValueString { | ||
&self.key | ||
} | ||
|
||
pub fn value(&self) -> Option<&HeaderValueString> { | ||
pub(super) fn value(&self) -> Option<&HeaderValueString> { | ||
self.value.as_ref() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
pub mod robots_tag; | ||
pub use robots_tag::RobotsTag; | ||
mod robots_tag; | ||
|
||
pub mod robots_tag_builder; | ||
pub use robots_tag_builder::RobotsTagBuilder; | ||
mod robots_tag_builder; | ||
|
||
pub mod max_image_preview_setting; | ||
pub use max_image_preview_setting::MaxImagePreviewSetting; | ||
mod max_image_preview_setting; | ||
|
||
pub mod custom_rule; | ||
pub use custom_rule::CustomRule; | ||
mod custom_rule; | ||
mod valid_date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use chrono::{DateTime, Utc}; | ||
use rama_core::error::OpaqueError; | ||
use std::ops::Deref; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub(super) struct ValidDate(DateTime<Utc>); | ||
|
||
impl ValidDate { | ||
pub(super) fn new(date: DateTime<Utc>) -> Result<Self, OpaqueError> { | ||
Ok(Self(date)) | ||
} | ||
} | ||
|
||
impl Deref for ValidDate { | ||
type Target = DateTime<Utc>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl From<ValidDate> for DateTime<Utc> { | ||
fn from(value: ValidDate) -> Self { | ||
value.0 | ||
} | ||
} | ||
|
||
impl TryFrom<DateTime<Utc>> for ValidDate { | ||
type Error = OpaqueError; | ||
|
||
fn try_from(value: DateTime<Utc>) -> Result<Self, Self::Error> { | ||
ValidDate::new(value) | ||
} | ||
} | ||
|
||
impl AsRef<DateTime<Utc>> for ValidDate { | ||
fn as_ref(&self) -> &DateTime<Utc> { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl AsMut<DateTime<Utc>> for ValidDate { | ||
fn as_mut(&mut self) -> &mut DateTime<Utc> { | ||
&mut self.0 | ||
} | ||
} |