sia_rs

Crates.iosia_rs
lib.rssia_rs
version0.5.0
sourcesrc
created_at2024-04-06 15:54:39.447518
updated_at2024-11-07 21:36:43.722301
descriptionA Rust library for interacting with the UK SIA Register
homepagehttps://github.com/LordOfPolls/sia_rs
repositoryhttps://github.com/LordOfPolls/sia_rs
max_upload_size
id1198379
size41,939
LordOfPolls (LordOfPolls)

documentation

README

SIA_RS

A rust library for searching the UK's Security Industry Authority (SIA) register of licenced security operatives.

Providing an easy-to use interface for searching by licenses by licence number or details of the licence holder.

Features

  • Search for licenses by details (first name, last name, middle name, date of birth, role, and sector)
  • Search for licenses by license number
  • Returns all public information about the license holder
  • Asynchronous and synchronous search functions
    • Synchronous functions are available with the blocking feature
  • Full enum mapping for all possible roles and sectors

Usage

use sia_rs::{Query, search};

#[tokio::main]
async fn main() {
    let query = Query::new()
        .with_last_name("Smith".to_string())
        .with_first_name("John".to_string());

    let results: Result<Vec<LicenseState>, RequestError> = search(&query).await;

    match results {
        Ok(licenses) => {
            for license in licenses {
                println!("{}", license);
            }
        },
        Err(e) => println!("Error: {}", e),
    }

    let query = Query::new()
        .with_license_number("1234567890123456".to_string());

    let results = search(&query).await;

    match results {
        Ok(licenses) => {
            for license in licenses {
                println!("{}", license);
            }
        },
        Err(e) => println!("Error: {}", e),
    }
}

All interactions are done through the Query struct, which is used to build the search query. The search function is used to perform the search and returns a Vec<License> containing the results.

Blocking

The search_sync function is a blocking function that will wait for the search to complete before returning the results. This function is only available with the blocking feature enabled.

[dependencies]
sia_rs = { version = "*", features = ["blocking"] }

Testing

Some tests require real data and will only run if certain environment variables are set:

  • KNOWN_FIRST_NAME - The first name of a known license holder
  • KNOWN_LAST_NAME - The last name of a known license holder
  • KNOWN_LICENSE_NUMBER - The license number of a known license holder

These are not included in the source code for privacy reasons.

Notice

The SIA does not provide an official API for accessing the register, this library uses web scraping to retrieve the data. This means that the library may break if the SIA changes the structure of their website.

The author of this library is not responsible for any misuse of the data retrieved by this library.

Contributing

Contributions are welcome, please open an issue or pull request.

Commit count: 26

cargo fmt