use crate::prelude::*;
mod get;
mod set;
mod filter;
#[repr(transparent)]
#[derive(Debug, Clone, Default)]
pub struct MaybeFragmentQuery<'a>(pub Option<FragmentQuery<'a>>);
impl<'a> MaybeFragmentQuery<'a> {
pub fn as_str(&self) -> Option<&str> {
self.0.as_ref().map(FragmentQuery::as_str)
}
pub fn is_some(&self) -> bool {
self.0.is_some()
}
pub fn is_none(&self) -> bool {
self.0.is_none()
}
pub fn string(self) -> MaybeFragment<'a> {
self.into()
}
pub unsafe fn new_unchecked<T: Into<Cow<'a, str>>>(value: Option<T>) -> Self {
unsafe {
Self(value.map(|x| FragmentQuery::new_unchecked(x)))
}
}
pub fn into_inner(self) -> Option<Cow<'a, str>> {
self.0.map(FragmentQuery::into_inner)
}
pub fn into_owned(self) -> MaybeFragmentQuery<'static> {
MaybeFragmentQuery(self.0.map(FragmentQuery::into_owned))
}
pub fn borrowed(&self) -> MaybeFragmentQuery<'_> {
MaybeFragmentQuery(self.0.as_ref().map(FragmentQuery::borrowed))
}
}
impl<'a> From<Option<Cow<'a, [u8]>>> for MaybeFragmentQuery<'a> {
fn from(value: Option<Cow<'a, [u8]>>) -> Self {
Self(value.map(Into::into))
}
}
impl<'a> From<MaybeQueryLike<'a>> for MaybeFragmentQuery<'a> {
fn from(value: MaybeQueryLike<'a>) -> Self {
match value {
MaybeQueryLike::Query (x) => x.into(),
MaybeQueryLike::Fragment(x) => x,
}
}
}
impl<'a> From<MaybeQuery<'a>> for MaybeFragmentQuery<'a> {
fn from(value: MaybeQuery<'a>) -> Self {
match value {
MaybeQuery::Special (x) => x.into(),
MaybeQuery::NonSpecial(x) => x.into(),
}
}
}
impl<'a> From<MaybeFragment <'a> > for MaybeFragmentQuery<'a> {fn from(value: MaybeFragment <'a> ) -> Self {Self(value.0.map(Into::into))}}
impl<'a> From<MaybeSpecialQuery <'a> > for MaybeFragmentQuery<'a> {fn from(value: MaybeSpecialQuery <'a> ) -> Self {Self(value.0.map(Into::into))}}
impl<'a> From<MaybeNonSpecialQuery <'a> > for MaybeFragmentQuery<'a> {fn from(value: MaybeNonSpecialQuery <'a> ) -> Self {Self(value.0.map(Into::into))}}
impl<'a> From<Option<QueryLike <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<QueryLike <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<FragmentQuery <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<FragmentQuery <'a>>) -> Self {Self(value )}}
impl<'a> From<Option<Fragment <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<Fragment <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<Query <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<Query <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<SpecialQuery <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<SpecialQuery <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<NonSpecialQuery <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<NonSpecialQuery <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<QueryLikeSegment <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<QueryLikeSegment <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<FragmentQuerySegment <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<FragmentQuerySegment <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<QuerySegment <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<QuerySegment <'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<NonSpecialQuerySegment<'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<NonSpecialQuerySegment<'a>>) -> Self {Self(value.map(Into::into))}}
impl<'a> From<Option<SpecialQuerySegment <'a>>> for MaybeFragmentQuery<'a> {fn from(value: Option<SpecialQuerySegment <'a>>) -> Self {Self(value.map(Into::into))}}