Elffuss BraidHub

kikocis/lancedb public

main · 1.8 KiBRawPermalink
1// Copyright 2024 Lance Developers.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use lazy_static::lazy_static;
16
17// TODO import from lance-jni without duplicate
18#[macro_export]
19macro_rules! ok_or_throw {
20 ($env:expr, $result:expr) => {
21 match $result {
22 Ok(value) => value,
23 Err(err) => {
24 Error::from(err).throw(&mut $env);
25 return JObject::null();
26 }
27 }
28 };
29}
30
31macro_rules! ok_or_throw_without_return {
32 ($env:expr, $result:expr) => {
33 match $result {
34 Ok(value) => value,
35 Err(err) => {
36 Error::from(err).throw(&mut $env);
37 return;
38 }
39 }
40 };
41}
42
43#[macro_export]
44macro_rules! ok_or_throw_with_return {
45 ($env:expr, $result:expr, $ret:expr) => {
46 match $result {
47 Ok(value) => value,
48 Err(err) => {
49 Error::from(err).throw(&mut $env);
50 return $ret;
51 }
52 }
53 };
54}
55
56mod connection;
57pub mod error;
58mod ffi;
59mod traits;
60
61pub use error::{Error, Result};
62
63lazy_static! {
64 static ref RT: tokio::runtime::Runtime = tokio::runtime::Builder::new_multi_thread()
65 .enable_all()
66 .build()
67 .expect("Failed to create tokio runtime");
68}