mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-04 19:02:58 +00:00
58 lines
1.3 KiB
Rust
58 lines
1.3 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
// TODO import from lance-jni without duplicate
|
|
#[macro_export]
|
|
macro_rules! ok_or_throw {
|
|
($env:expr, $result:expr) => {
|
|
match $result {
|
|
Ok(value) => value,
|
|
Err(err) => {
|
|
Error::from(err).throw(&mut $env);
|
|
return JObject::null();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
macro_rules! ok_or_throw_without_return {
|
|
($env:expr, $result:expr) => {
|
|
match $result {
|
|
Ok(value) => value,
|
|
Err(err) => {
|
|
Error::from(err).throw(&mut $env);
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! ok_or_throw_with_return {
|
|
($env:expr, $result:expr, $ret:expr) => {
|
|
match $result {
|
|
Ok(value) => value,
|
|
Err(err) => {
|
|
Error::from(err).throw(&mut $env);
|
|
return $ret;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
mod connection;
|
|
pub mod error;
|
|
mod ffi;
|
|
mod traits;
|
|
|
|
pub use error::{Error, Result};
|
|
|
|
lazy_static! {
|
|
static ref RT: tokio::runtime::Runtime = tokio::runtime::Builder::new_multi_thread()
|
|
.enable_all()
|
|
.build()
|
|
.expect("Failed to create tokio runtime");
|
|
}
|