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 options::Options,
23 promise::{box_promise, BoxPromise, Promise},
24 stream::{box_stream, BoxStream},
25};
26
27pub(crate) mod address;
28pub mod error;
29mod id;
30pub mod info;
31mod options;
32#[cfg_attr(not(feature = "sync"), path = "promise_async.rs")]
33#[cfg_attr(feature = "sync", path = "promise_sync.rs")]
34mod promise;
35#[cfg_attr(not(feature = "sync"), path = "stream_async.rs")]
36#[cfg_attr(feature = "sync", path = "stream_sync.rs")]
37pub mod stream;
38
39pub(crate) type Callback = Box<dyn FnOnce() + Send>;
40
41pub(crate) type StdResult<T, E> = std::result::Result<T, E>;
42pub type Result<T = ()> = StdResult<T, Error>;
43
44pub type IID = id::ID;
45pub(crate) type RequestID = id::ID;
46
47/// This enum is used to specify the type of transaction.
48///
49/// # Examples
50///
51/// ```rust
52/// database.transaction(TransactionType::Read)
53/// ```
54#[repr(C)]
55#[derive(Copy, Clone, Debug, Eq, PartialEq)]
56pub enum TransactionType {
57 Read = 0,
58 Write = 1,
59 Schema = 2,
60}