Skip to main content

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