forked from sparckles/Robyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
52 lines (45 loc) · 1.23 KB
/
lib.rs
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
mod executors;
mod io_helpers;
mod routers;
mod server;
mod shared_socket;
mod types;
mod websockets;
use server::Server;
use shared_socket::SocketHeld;
// pyO3 module
use pyo3::prelude::*;
use types::{
function_info::{FunctionInfo, MiddlewareType},
headers::Headers,
identity::Identity,
multimap::QueryParams,
request::PyRequest,
response::PyResponse,
HttpMethod, Url,
};
use websockets::{registry::WebSocketRegistry, WebSocketConnector};
#[pyfunction]
fn get_version() -> String {
env!("CARGO_PKG_VERSION").into()
}
#[pymodule]
pub fn robyn(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
// the pymodule class/function to make the rustPyFunctions available
m.add_function(wrap_pyfunction!(get_version, m)?)?;
m.add_class::<Server>()?;
m.add_class::<Headers>()?;
m.add_class::<WebSocketRegistry>()?;
m.add_class::<WebSocketConnector>()?;
m.add_class::<SocketHeld>()?;
m.add_class::<FunctionInfo>()?;
m.add_class::<Identity>()?;
m.add_class::<PyRequest>()?;
m.add_class::<PyResponse>()?;
m.add_class::<Url>()?;
m.add_class::<QueryParams>()?;
m.add_class::<MiddlewareType>()?;
m.add_class::<HttpMethod>()?;
pyo3::prepare_freethreaded_python();
Ok(())
}