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
//! Rocket integration of Toql. //! This contains //! - A high level function to query Toql structs. //! - Query parameters. //! - Support to add counting information to HTTP response headers //! //! This allows to query Toql structs like this //! //! ```ignore //! #[macro_use] //! extern crate rocket; //! #[macro_use] //! extern crate rocket_contrib; //! //! use toql_rocket::{ToqlQuery, Counted, Result, mysql::load_many, toql::sql_mapper::SqlMapperCache}; //! use rocket::request::Form; //! use rocket_contrib::json::Json; //! use myql::Conn; //! //! #[database("example_db")] //! struct ExampleDbConnection(mysql::Conn); //! //! struct User {id:u64, username: Option<String>}; //! //! #[get("/?<toql..>")] //! fn query( mappers: State<SqlMapperCache>, //! conn: ExampleDbConnection, //! toql: Form<ToqlQuery>) //! -> Result<Counted<Json<Vec<User>>>> { //! let ExampleDbConnection(mut c) = conn; //! //! let r = load_many::<User>(&toql, &mappers, &mut c)?; //! Ok(Counted(Json(r.0), r.1)) //! } //! //! ``` //! //! pub mod counted; pub mod query; pub mod error; #[cfg(feature = "mysql")] pub mod mysql; pub use counted::Counted; pub use query::ToqlQuery; pub use error::Result; pub use toql; // Reexport #[cfg(feature = "mysql")] pub use mysql::load_many;