make sqlx_core::runtime private and add a runtime module to sqlx-macros

This commit is contained in:
Ryan Leckey
2020-03-24 01:19:03 -07:00
parent e2f90c8f85
commit 0182ce92f2
6 changed files with 27 additions and 20 deletions

View File

@@ -7,6 +7,9 @@
#![cfg_attr(not(feature = "sqlite"), forbid(unsafe_code))]
#![recursion_limit = "512"]
#![cfg_attr(docsrs, feature(doc_cfg))]
// #![warn(missing_docs)]
mod runtime;
#[macro_use]
pub mod error;
@@ -25,9 +28,6 @@ pub mod executor;
pub mod transaction;
mod url;
#[doc(hidden)]
pub mod runtime;
#[macro_use]
pub mod arguments;
pub mod decode;

View File

@@ -1,22 +1,24 @@
#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
compile_error!("one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
#[cfg(all(feature = "runtime-tokio", feature = "runtime-async-std"))]
compile_error!("only one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
#[cfg(feature = "runtime-async-std")]
pub use async_std::{
fs,
pub(crate) use async_std::{
future::timeout,
io::prelude::{ReadExt as AsyncReadExt, WriteExt as AsyncWriteExt},
io::prelude::ReadExt as AsyncReadExt,
io::{Read as AsyncRead, Write as AsyncWrite},
net::TcpStream,
task::sleep,
task::spawn,
task::yield_now,
};
#[cfg(feature = "runtime-tokio")]
pub use tokio::{
fs,
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
pub(crate) use tokio::{
io::{AsyncRead, AsyncReadExt, AsyncWrite},
net::TcpStream,
task::spawn,
task::yield_now,
time::delay_for as sleep,
time::timeout,
};

View File

@@ -18,10 +18,9 @@ type Error = Box<dyn std::error::Error>;
type Result<T> = std::result::Result<T, Error>;
mod database;
mod derives;
mod query_macros;
mod runtime;
use query_macros::*;

View File

@@ -11,7 +11,8 @@ use syn::{ExprGroup, Token};
use sqlx::connection::Connection;
use sqlx::describe::Describe;
use sqlx::runtime::fs;
use crate::runtime::fs;
/// Macro input shared by `query!()` and `query_file!()`
pub struct QueryMacroInput {

View File

@@ -0,0 +1,11 @@
#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
compile_error!("one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
#[cfg(all(feature = "runtime-tokio", feature = "runtime-async-std"))]
compile_error!("only one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
#[cfg(feature = "runtime-async-std")]
pub(crate) use async_std::fs;
#[cfg(feature = "runtime-tokio")]
pub(crate) use tokio::fs;

View File

@@ -1,11 +1,5 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
compile_error!("one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
#[cfg(all(feature = "runtime-tokio", feature = "runtime-async-std"))]
compile_error!("only one of 'runtime-async-std' or 'runtime-tokio' features must be enabled");
pub use sqlx_core::arguments;
pub use sqlx_core::connection::{Connect, Connection};
pub use sqlx_core::cursor::Cursor;