ifsc 0.1.1

A fast offline directory for Indian bank branches and IFSCs
Documentation
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// A bank-name entry in the bundled Razorpay snapshot.
pub struct Bank(pub(crate) u32);
impl Bank {
    fn row(self) -> crate::snapshot::BankNameView {
        crate::snapshot::bank_name(self.0).expect("valid bank handle")
    }
    /// Returns the bank code.
    pub fn code(self) -> crate::BankCode {
        self.row().code()
    }
    /// Returns Razorpay's reported bank name.
    pub fn name(self) -> &'static str {
        self.row().name()
    }
    /// Returns separate bank-level metadata when Razorpay reports it.
    pub fn profile(self) -> Option<BankProfile> {
        self.code().profile()
    }
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// Bank-level metadata reported by Razorpay.
pub struct BankProfile(pub(crate) u32);
impl BankProfile {
    fn row(self) -> crate::snapshot::BankView {
        crate::snapshot::bank_profile(self.0).expect("valid profile handle")
    }
    /// Returns the profile's bank code.
    pub fn code(self) -> crate::BankCode {
        self.row().code()
    }
    /// Returns the corresponding bank-name entry.
    pub fn bank(self) -> Bank {
        self.code().bank().expect("generated bank name")
    }
    /// Returns Razorpay's bank classification.
    pub fn kind(self) -> BankKind {
        self.row().kind()
    }
    /// Returns Razorpay's reference IFSC, if reported and well formed.
    pub fn reference_ifsc(self) -> Option<crate::Ifsc> {
        self.row().reference_ifsc()
    }
    /// Returns the reported MICR value without numeric interpretation.
    pub fn micr(self) -> Option<&'static str> {
        self.row().text(0)
    }
    /// Returns the reported issuer identification number as text.
    pub fn iin(self) -> Option<&'static str> {
        self.row().text(1)
    }
    /// Returns Razorpay's tri-state report for a bank-level service.
    pub fn reported_status(self, service: BankService) -> ReportedStatus {
        self.row().status(service)
    }
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// A bank classification reported by Razorpay.
pub enum BankKind {
    /// A district central cooperative bank.
    DistrictCentralCooperative,
    /// A foreign bank.
    Foreign,
    /// A local area bank.
    LocalArea,
    /// A bank in Razorpay's other urban cooperative category.
    OtherUrbanCooperative,
    /// A payments bank.
    Payments,
    /// A public-sector bank.
    PublicSector,
    /// A private-sector bank.
    Private,
    /// A regional rural bank.
    RegionalRural,
    /// A scheduled urban cooperative bank.
    ScheduledUrbanCooperative,
    /// A state cooperative bank.
    StateCooperative,
    /// A small finance bank.
    SmallFinance,
}
impl BankKind {
    /// Returns Razorpay's source code for this classification.
    pub const fn source_code(self) -> &'static str {
        match self {
            Self::DistrictCentralCooperative => "DCCB",
            Self::Foreign => "Foreign",
            Self::LocalArea => "LAB",
            Self::OtherUrbanCooperative => "O-UCB",
            Self::Payments => "PB",
            Self::PublicSector => "PSB",
            Self::Private => "Private",
            Self::RegionalRural => "RRB",
            Self::ScheduledUrbanCooperative => "S-UCB",
            Self::StateCooperative => "SCB",
            Self::SmallFinance => "SFB",
        }
    }
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// A bank-level service represented in Razorpay metadata.
pub enum BankService {
    /// Automated Clearing House credit.
    AchCredit,
    /// Automated Clearing House debit.
    AchDebit,
    /// Aadhaar Payment Bridge System.
    Apbs,
    /// National Automated Clearing House debit.
    NachDebit,
    /// Unified Payments Interface.
    Upi,
    /// Immediate Payment Service.
    Imps,
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
/// Razorpay's reported state for a bank-level service.
pub enum ReportedStatus {
    /// Razorpay reports the service as available.
    Available,
    /// Razorpay reports the service as unavailable.
    Unavailable,
    /// Razorpay does not report this service for the bank.
    NotReported,
}