pub struct SerializableRegex { /* private fields */ }Expand description
A wrapper type for fancy_regex::Regex that implements Serialize, Deserialize, PartialEq, Eq
This wrapper allows storing and serializing regular expressions by storing the pattern string alongside the compiled regex object.
§Examples
use gooty_proxy::utils::SerializableRegex;
let regex = SerializableRegex::new(r"\d{3}").unwrap();
assert!(regex.is_match("123").unwrap());
// Serialize and deserialize with serde
let serialized = serde_json::to_string(®ex).unwrap();
let deserialized: SerializableRegex = serde_json::from_str(&serialized).unwrap();
assert_eq!(regex, deserialized);Implementations§
Trait Implementations§
Source§impl Clone for SerializableRegex
impl Clone for SerializableRegex
Source§fn clone(&self) -> SerializableRegex
fn clone(&self) -> SerializableRegex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SerializableRegex
impl Debug for SerializableRegex
Source§impl Display for SerializableRegex
impl Display for SerializableRegex
impl Eq for SerializableRegex
Source§impl FromStr for SerializableRegex
impl FromStr for SerializableRegex
Source§impl Hash for SerializableRegex
impl Hash for SerializableRegex
Source§impl PartialEq for SerializableRegex
impl PartialEq for SerializableRegex
Auto Trait Implementations§
impl Freeze for SerializableRegex
impl RefUnwindSafe for SerializableRegex
impl Send for SerializableRegex
impl Sync for SerializableRegex
impl Unpin for SerializableRegex
impl UnsafeUnpin for SerializableRegex
impl UnwindSafe for SerializableRegex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.