subxt_utils_fetchmetadata/
lib.rs1#![cfg_attr(docsrs, feature(doc_cfg))]
8
9#[macro_use]
11mod macros;
12mod error;
13
14cfg_fetch_from_url! {
15 mod url;
16 pub use url::{from_url, from_url_blocking, MetadataVersion, Url};
17}
18
19pub use error::Error;
20
21pub fn from_file_blocking(path: &std::path::Path) -> Result<Vec<u8>, error::Error> {
23 use std::io::Read;
24
25 let to_err = |err| error::Error::Io(path.to_string_lossy().into(), err);
26 let mut file = std::fs::File::open(path).map_err(to_err)?;
27 let mut bytes = Vec::new();
28 file.read_to_end(&mut bytes).map_err(to_err)?;
29 Ok(bytes)
30}