typedb_driver/common/mod.rs
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20pub use self::{
21 error::Error,
22 promise::{box_promise, BoxPromise, Promise},
23 query_options::QueryOptions,
24 stream::{box_stream, BoxStream},
25 transaction_options::TransactionOptions,
26};
27
28pub(crate) mod address;
29pub mod error;
30mod id;
31pub mod info;
32#[cfg_attr(not(feature = "sync"), path = "promise_async.rs")]
33#[cfg_attr(feature = "sync", path = "promise_sync.rs")]
34mod promise;
35mod query_options;
36#[cfg_attr(not(feature = "sync"), path = "stream_async.rs")]
37#[cfg_attr(feature = "sync", path = "stream_sync.rs")]
38pub mod stream;
39mod transaction_options;
40
41pub(crate) type Callback = Box<dyn FnOnce() + Send>;
42
43pub(crate) type StdResult<T, E> = std::result::Result<T, E>;
44pub type Result<T = ()> = StdResult<T, Error>;
45
46pub type IID = id::ID;
47pub(crate) type RequestID = id::ID;
48
49/// This enum is used to specify the type of transaction.
50///
51/// # Examples
52///
53/// ```rust
54/// database.transaction(TransactionType::Read)
55/// ```
56#[repr(C)]
57#[derive(Copy, Clone, Debug, Eq, PartialEq)]
58pub enum TransactionType {
59 Read = 0,
60 Write = 1,
61 Schema = 2,
62}