Struct Zengin

Source
pub struct Zengin { /* private fields */ }
Expand description

The Zengin struct represents a collection of banks and their branches.

This struct provides methods to load bank and branch data from JSON files, and to retrieve information about banks and branches.

Implementations§

Source§

impl Zengin

Source

pub fn new() -> Result<Zengin, Box<dyn Error>>

Creates a new instance of Zengin by loading bank and branch data from JSON files.

This function reads the banks.json file to load bank data and then reads corresponding branch JSON files for each bank to load branch data.

§Errors

Returns an error if any of the JSON files cannot be read or parsed.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
Source

pub fn get_bank(&self, code: &str) -> Option<&Bank>

Retrieves a reference to a bank by its code.

This function takes a bank code as input and returns an Option containing a reference to the corresponding Bank if it exists.

§Arguments
  • code - A string slice that holds the bank code.
§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
if let Some(bank) = zengin.get_bank("0001") {
    println!("Found bank: {}", bank.name);
}
Source

pub fn find_banks_by_name(&self, pattern: &str) -> Result<Vec<&Bank>, Error>

Finds banks by their name using a regular expression pattern.

This function takes a regular expression pattern as input and returns a vector of references to the banks whose names match the pattern.

§Arguments
  • pattern - A string slice that holds the regular expression pattern.
§Errors

Returns an error if the regular expression pattern is invalid.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
let banks = zengin.find_banks_by_name(".*みずほ.*").unwrap();
for bank in banks {
    println!("Found bank: {}", bank.name);
}
Source

pub fn find_banks_by_kana(&self, pattern: &str) -> Result<Vec<&Bank>, Error>

Finds banks by their kana name using a regular expression pattern.

This function takes a regular expression pattern as input and returns a vector of references to the banks whose names match the pattern.

§Arguments
  • pattern - A string slice that holds the regular expression pattern.
§Errors

Returns an error if the regular expression pattern is invalid.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
let banks = zengin.find_banks_by_kana(".*ミズホ.*").unwrap();
for bank in banks {
    println!("Found bank: {}", bank.name);
}
Source

pub fn find_banks_by_hira(&self, pattern: &str) -> Result<Vec<&Bank>, Error>

Finds banks by their hiragana name using a regular expression pattern.

This function takes a regular expression pattern as input and returns a vector of references to the banks whose names match the pattern.

§Arguments
  • pattern - A string slice that holds the regular expression pattern.
§Errors

Returns an error if the regular expression pattern is invalid.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
let banks = zengin.find_banks_by_hira(".*みずほ.*").unwrap();
for bank in banks {
    println!("Found bank: {}", bank.name);
}
Source

pub fn find_banks_by_roma(&self, pattern: &str) -> Result<Vec<&Bank>, Error>

Finds banks by their romanized name using a regular expression pattern.

This function takes a regular expression pattern as input and returns a vector of references to the banks whose names match the pattern.

§Arguments
  • pattern - A string slice that holds the regular expression pattern.
§Errors

Returns an error if the regular expression pattern is invalid.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
let banks = zengin.find_banks_by_roma(".*mizuho.*").unwrap();
for bank in banks {
    println!("Found bank: {}", bank.name);
}
Source

pub fn all_banks(&self) -> &HashMap<String, Bank>

Retrieves a reference to all banks.

This function returns a reference to the internal HashMap containing all banks.

§Examples
use zengin::Zengin;
let zengin = Zengin::new().unwrap();
let banks = zengin.all_banks();
for (code, bank) in banks {
    println!("Bank code: {}, Bank name: {}", code, bank.name);
}

Auto Trait Implementations§

§

impl Freeze for Zengin

§

impl RefUnwindSafe for Zengin

§

impl Send for Zengin

§

impl Sync for Zengin

§

impl Unpin for Zengin

§

impl UnwindSafe for Zengin

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.