use super::structure::DiveBase;
const MISSING_DIVE_BASE_ID: &str = "Dive base ID is required";
pub struct DiveBaseBuilder {
id: Option<String>,
name: Option<String>,
}
impl DiveBaseBuilder {
pub fn new() -> Self {
DiveBaseBuilder {
id: None,
name: None,
}
}
pub fn id(mut self, id: String) -> Self {
self.id = Some(id);
self
}
pub fn name(mut self, name: String) -> Self {
self.name = Some(name);
self
}
pub fn build(self) -> Result<DiveBase, &'static str> {
Ok(DiveBase {
id: self.id.ok_or(MISSING_DIVE_BASE_ID)?,
name: self.name,
})
}
}
impl Default for DiveBaseBuilder {
fn default() -> Self {
Self::new()
}
}