ifsc 0.1.1

A fast offline directory for Indian bank branches and IFSCs
Documentation
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// The Razorpay mapping that produced a sub-member match.
pub enum SubletSource {
    /// An exact 11-character IFSC mapping.
    Exact,
    /// A custom IFSC-prefix mapping.
    CustomPrefix,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// The institution reported for a sub-member mapping.
pub enum SubletTarget {
    /// A resolved Razorpay bank code.
    Bank(crate::BankCode),
    /// A source name without a corresponding bank-code entry.
    ReportedName(&'static str),
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// One exact or prefix sub-member match.
pub struct SubletMatch {
    pub(crate) source: SubletSource,
    pub(crate) prefix: &'static str,
    pub(crate) target: SubletTarget,
}
impl SubletMatch {
    /// Returns the mapping source.
    pub fn source(self) -> SubletSource {
        self.source
    }
    /// Returns the exact code or prefix that matched.
    pub fn matched_prefix(self) -> &'static str {
        self.prefix
    }
    /// Returns the institution reported by the mapping.
    pub fn target(self) -> SubletTarget {
        self.target
    }
}

#[derive(Clone)]
/// Matches custom Razorpay sub-member prefixes for one IFSC.
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 {}