use crate::schema::service_root::Expand;
use crate::schema::service_root::ProtocolFeaturesSupported;
use std::convert::identity;
#[derive(Default)]
pub struct ProtocolFeatures {
pub expand: ExpandQueryFeatures,
}
impl ProtocolFeatures {
pub(crate) fn new(f: &ProtocolFeaturesSupported) -> Self {
Self {
expand: f
.expand_query
.as_ref()
.map(ExpandQueryFeatures::new)
.unwrap_or_default(),
}
}
}
pub struct ExpandQueryFeatures {
pub expand_all: bool,
pub no_links: bool,
}
#[allow(clippy::derivable_impls)]
impl Default for ExpandQueryFeatures {
fn default() -> Self {
Self {
expand_all: false,
no_links: false,
}
}
}
impl ExpandQueryFeatures {
pub fn new(f: &Expand) -> Self {
Self {
expand_all: f.expand_all.is_some_and(identity),
no_links: f.no_links.is_some_and(identity),
}
}
}