use super::*;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct UpdatePolicy {
channel: String,
automatic: bool,
}
impl UpdatePolicy {
pub fn new(channel: impl Into<String>, automatic: bool) -> ContractResult<Self> {
let policy = Self {
channel: channel.into(),
automatic,
};
policy.validate()?;
Ok(policy)
}
pub fn channel(&self) -> &str {
&self.channel
}
pub fn is_automatic(&self) -> bool {
self.automatic
}
pub(crate) fn validate(&self) -> ContractResult<()> {
validate_text("update.channel", &self.channel, 64)
}
}