abstio/
lib.rs

1//! A/B Street organizes data files [in a particular
2//! way](https://a-b-street.github.io/docs/tech/dev/data.html). This crate implements methods to
3//! find files and (mostly) treat them the same way on native and web.
4
5#![allow(clippy::type_complexity)]
6
7#[macro_use]
8extern crate anyhow;
9#[macro_use]
10extern crate log;
11
12#[cfg(not(target_arch = "wasm32"))]
13mod io_native;
14#[cfg(not(target_arch = "wasm32"))]
15pub use io_native::*;
16#[cfg(target_arch = "wasm32")]
17mod io_web;
18#[cfg(target_arch = "wasm32")]
19pub use io_web::*;
20
21#[cfg(not(target_arch = "wasm32"))]
22mod download;
23#[cfg(not(target_arch = "wasm32"))]
24pub use download::*;
25
26pub use abst_data::*;
27pub use abst_paths::*;
28pub use http::*;
29
30mod abst_data;
31mod abst_paths;
32mod http;
33mod io;
34
35/// An adapter for widgetry::Settings::read_svg to read SVGs using this crate's methods for finding
36/// and reading files in different environments.
37pub fn slurp_bytes(filename: &str) -> Vec<u8> {
38    let path = path(filename);
39    slurp_file(&path).unwrap_or_else(|err| panic!("Can't read {}: {}", path, err))
40}