#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum SubletSource {
Exact,
CustomPrefix,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum SubletTarget {
Bank(crate::BankCode),
ReportedName(&'static str),
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SubletMatch {
pub(crate) source: SubletSource,
pub(crate) prefix: &'static str,
pub(crate) target: SubletTarget,
}
impl SubletMatch {
pub fn source(self) -> SubletSource {
self.source
}
pub fn matched_prefix(self) -> &'static str {
self.prefix
}
pub fn target(self) -> SubletTarget {
self.target
}
}
#[derive(Clone)]
pub struct CustomSubletMatches {
pub(crate) ifsc: crate::Ifsc,
pub(crate) cursor: u32,
}
impl Iterator for CustomSubletMatches {
type Item = SubletMatch;
fn next(&mut self) -> Option<Self::Item> {
while self.cursor < crate::snapshot::custom_sublet_count() {
let i = self.cursor;
self.cursor += 1;
let m = crate::snapshot::custom_sublet(i)?;
if m.matches(self.ifsc) {
return Some(m.view());
}
}
None
}
}
impl core::iter::FusedIterator for CustomSubletMatches {}