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(crate) mod address;
21pub mod error;
22mod id;
23pub mod info;
24mod options;
25#[cfg_attr(not(feature = "sync"), path = "promise_async.rs")]
26#[cfg_attr(feature = "sync", path = "promise_sync.rs")]
27mod promise;
28#[cfg_attr(not(feature = "sync"), path = "stream_async.rs")]
29#[cfg_attr(feature = "sync", path = "stream_sync.rs")]
30pub mod stream;
31
32pub use self::{
33    error::Error,
34    options::Options,
35    promise::{box_promise, BoxPromise, Promise},
36    stream::{box_stream, BoxStream},
37};
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;
46pub(crate) type SessionID = id::ID;
47
48/// This enum is used to specify the type of the session.
49///
50/// # Examples
51///
52/// ```rust
53/// Session::new(database, SessionType::Schema).await
54/// ```
55#[repr(C)]
56#[derive(Copy, Clone, Debug, Eq, PartialEq)]
57pub enum SessionType {
58    Data = 0,
59    Schema = 1,
60}
61
62/// This enum is used to specify the type of transaction.
63///
64/// # Examples
65///
66/// ```rust
67/// session.transaction(TransactionType::READ)
68/// ```
69#[repr(C)]
70#[derive(Copy, Clone, Debug, Eq, PartialEq)]
71pub enum TransactionType {
72    Read = 0,
73    Write = 1,
74}