use crate::{AppId, RecordId, State, Status};
#[derive(Clone, Copy, Debug, Default)]
pub struct Context<'a> {
id: Option<RecordId<'a>>,
app: Option<AppId<'a>>,
title: Option<&'a str>,
}
impl<'a> Context<'a> {
#[must_use]
pub const fn new() -> Self {
Self {
id: None,
app: None,
title: None,
}
}
#[must_use]
pub const fn id(mut self, id: RecordId<'a>) -> Self {
self.id = Some(id);
self
}
#[must_use]
pub const fn app(mut self, app: AppId<'a>) -> Self {
self.app = Some(app);
self
}
#[must_use]
pub const fn title(mut self, title: &'a str) -> Self {
self.title = Some(title);
self
}
#[must_use]
pub const fn status(&self, state: State) -> Status<'a> {
Status {
id: self.id,
app: self.app,
title: self.title,
..Status::new(state)
}
}
}