1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2025 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
//! FFI escape-hatch surface — **hidden, feature-gated, not semver-stable**.
//!
//! The `questdb-rs-ffi` C-ABI crate builds the C / C++ / Python clients on top
//! of [`QuestDb`]. C and Python cannot express Rust lifetimes, so the C ABI
//! cannot hand out the lifetime-bound `BorrowedSender` / `BorrowedReader`
//! handles that the normal Rust API
//! uses. Instead it hands out *owned* (lifetime-free) handles that carry their
//! own pool reference internally, so a C caller can free its `questdb_db*`
//! before dropping outstanding `qwp_sender*` / `qwp_reader*`
//! handles. After the pool is closed those handles still return / drop safely;
//! new operations on them fail cleanly with `InvalidApiCall`.
//!
//! Those owned handles and the entry points that mint them live here, behind
//! the `ffi-support` feature, so they never appear on the public [`QuestDb`]
//! surface that ordinary Rust users see. **Rust users want the lifetime-bound
//! API** — [`QuestDb::borrow_sender`] and (with egress)
//! `QuestDb::borrow_reader` — which catch use-after-close
//! at compile time.
//!
//! Everything re-exported or defined here is `#[doc(hidden)]` via the module
//! gate and exempt from semver. Do not depend on it from regular Rust code.
use Duration;
use QuestDb;
use crateResult;
pub use ;
pub use ;
/// Borrow the store-and-forward QWP sender as an owned, lifetime-free handle.
///
/// FFI counterpart to [`QuestDb::borrow_sender`]; backs the C ABI's
/// `questdb_db_borrow_sender`.
/// Like [`borrow_sender_owned`] but retries the connect within `budget`
/// using the pool reconnect backoff (the cluster may be electing a
/// primary). Backs the C ABI's `questdb_db_borrow_sender_with_retry`.
/// Borrow a **direct** (non-store-and-forward) column-major sender as an
/// owned, lifetime-free handle. FFI counterpart to
/// [`QuestDb::borrow_direct_column_sender`]; backs the C ABI's
/// `questdb_db_borrow_direct_sender`.
/// Like [`borrow_direct_column_sender_owned`] but retries the connect within
/// `budget` using the reconnect backoff. Backs the C ABI's
/// `questdb_db_borrow_direct_sender_with_retry`.
/// Build a **direct** (non-store-and-forward) column-major sender from a
/// QWP/WebSocket config string, owning its own connection with no pool.
/// Backs the C ABI's `qwp_direct_sender_from_conf`.
/// Build a **direct** column-major sender from an already-configured
/// [`SenderBuilder`], owning its own connection with no pool — the builder's
/// full auth/TLS config (including options set programmatically rather than
/// via a config string) is honoured. Backs the C ABI's
/// `qwp_direct_sender_from_opts`.
/// The pool's failover budget (`reconnect_max_duration`, default 300s).
/// Exposed so the C ABI can let callers bound an overall failover deadline.
/// Borrow a query [`Reader`](crate::egress::Reader) as an owned, lifetime-free
/// handle. FFI counterpart to `QuestDb::borrow_reader`; backs the C ABI's
/// `questdb_db_borrow_reader`.
/// An opaque pool reference the FFI's reader wrapper holds to return readers
/// without exposing the pool internals. Cheap to clone.
/// Snapshot the number of idle (free) readers in the pool. Diagnostics only.
/// Snapshot the number of currently-borrowed readers. Diagnostics only.