forked from kylebarron/parquet-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.rs
More file actions
42 lines (37 loc) · 1.38 KB
/
Copy pathutils.rs
File metadata and controls
42 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use wasm_bindgen::prelude::*;
pub const MAX_EXACT_INTEGER: u64 = ((1u64 << f64::MANTISSA_DIGITS) - 1) as u64;
/// Call this function at least once during initialization to get better error
// messages if the underlying Rust code ever panics (creates uncaught errors).
#[cfg(feature = "console_error_panic_hook")]
#[wasm_bindgen(js_name = setPanicHook)]
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
console_error_panic_hook::set_once();
}
// A macro to provide `println!(..)`-style syntax for `console.log` logging.
#[cfg(target_arch = "wasm32")]
#[macro_export]
macro_rules! log {
( $( $t:tt )* ) => {
web_sys::console::log_1(&format!( $( $t )* ).into());
}
}
#[cfg(not(target_arch = "wasm32"))]
#[macro_export]
macro_rules! log {
( $( $t:tt )* ) => {
println!("LOG - {}", format!( $( $t )* ));
}
}
/// Raise an error if the input array is empty
pub fn assert_parquet_file_not_empty(parquet_file: &[u8]) -> Result<(), JsError> {
if parquet_file.is_empty() {
return Err(JsError::new("Empty input provided or not a Uint8Array."));
}
Ok(())
}