mod compile;
pub mod container;
pub mod image;
mod link;
pub mod name;
pub mod service;
pub mod types;
use std::hash::Hash;
use crate::scell::{
container::SCellContainer,
image::SCellImage,
link::Link,
name::SCellId,
service::Service,
types::target::{services::ServiceName, shell::ShellStmt},
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SCell {
image: SCellImage,
container: SCellContainer,
shell: ShellStmt,
services: Vec<(ServiceName, Service)>,
}
impl SCell {
pub fn shell(&self) -> &str {
&self.shell.0
}
pub fn container_id(&self) -> color_eyre::Result<SCellId> {
SCellId::new(|hasher| {
self.image.hash(hasher)?;
self.container.hash(hasher);
for (name, service) in &self.services {
name.hash(hasher);
service.image.hash(hasher)?;
service.container.hash(hasher);
}
Ok(())
})
}
pub fn image(&self) -> &SCellImage {
&self.image
}
pub fn container(&self) -> &SCellContainer {
&self.container
}
pub fn services(&self) -> impl Iterator<Item = &(ServiceName, Service)> {
self.services.iter()
}
}