surrealdb/api/engine/
mod.rs1pub mod any;
4#[cfg(any(
5 feature = "kv-mem",
6 feature = "kv-tikv",
7 feature = "kv-rocksdb",
8 feature = "kv-fdb",
9 feature = "kv-indxdb",
10 feature = "kv-surrealkv",
11))]
12pub mod local;
13#[cfg(any(feature = "protocol-http", feature = "protocol-ws"))]
14pub mod remote;
15#[doc(hidden)]
16pub mod tasks;
17
18use crate::sql::Value;
19use crate::sql::Values;
20use futures::Stream;
21use std::pin::Pin;
22use std::task::Context;
23use std::task::Poll;
24#[cfg(not(target_arch = "wasm32"))]
25use tokio::time::Instant;
26#[cfg(not(target_arch = "wasm32"))]
27use tokio::time::Interval;
28#[cfg(target_arch = "wasm32")]
29use wasmtimer::std::Instant;
30#[cfg(target_arch = "wasm32")]
31use wasmtimer::tokio::Interval;
32
33#[allow(dead_code)]
35fn value_to_values(v: Value) -> Values {
36 match v {
37 Value::Array(x) => {
38 let mut values = Values::default();
39 values.0 = x.0;
40 values
41 }
42 x => {
43 let mut values = Values::default();
44 values.0 = vec![x];
45 values
46 }
47 }
48}
49
50struct IntervalStream {
51 inner: Interval,
52}
53
54impl IntervalStream {
55 #[allow(unused)]
56 fn new(interval: Interval) -> Self {
57 Self {
58 inner: interval,
59 }
60 }
61}
62
63impl Stream for IntervalStream {
64 type Item = Instant;
65
66 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Instant>> {
67 self.inner.poll_tick(cx).map(Some)
68 }
69}