use std::ops::{Deref, DerefMut};
use disposition_model_common::Map;
use serde::{Deserialize, Serialize};
use crate::edge::{EdgeGroup, EdgeGroupId};
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
pub struct EdgeGroups(Map<EdgeGroupId, EdgeGroup>);
impl EdgeGroups {
pub fn new() -> Self {
Self::default()
}
pub fn with_capacity(capacity: usize) -> Self {
Self(Map::with_capacity(capacity))
}
pub fn into_inner(self) -> Map<EdgeGroupId, EdgeGroup> {
self.0
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl Deref for EdgeGroups {
type Target = Map<EdgeGroupId, EdgeGroup>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for EdgeGroups {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<Map<EdgeGroupId, EdgeGroup>> for EdgeGroups {
fn from(inner: Map<EdgeGroupId, EdgeGroup>) -> Self {
Self(inner)
}
}
impl FromIterator<(EdgeGroupId, EdgeGroup)> for EdgeGroups {
fn from_iter<I: IntoIterator<Item = (EdgeGroupId, EdgeGroup)>>(iter: I) -> Self {
Self(Map::from_iter(iter))
}
}