diff --git a/python/src/lib.rs b/python/src/lib.rs index 26be624..7eafa43 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -4,6 +4,7 @@ mod decoder; mod enums; mod geo; mod ifd; +mod reader; mod thread_pool; mod tiff; mod tile; diff --git a/python/src/reader/aiohttp.rs b/python/src/reader/aiohttp.rs new file mode 100644 index 0000000..3f9e4a7 --- /dev/null +++ b/python/src/reader/aiohttp.rs @@ -0,0 +1,28 @@ +use pyo3::exceptions::PyTypeError; +use pyo3::intern; +use pyo3::prelude::*; +use pyo3::pybacked::PyBackedStr; + +struct AiohttpSession(PyObject); + +impl<'py> FromPyObject<'py> for AiohttpSession { + fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { + let py = ob.py(); + let cls = ob.getattr(intern!(py, "__class__"))?; + let module = cls + .getattr(intern!(py, "__module__"))? + .extract::()?; + let class_name = cls + .getattr(intern!(py, "__name__"))? + .extract::()?; + if module.starts_with("aiohttp") && class_name == "ClientSession" { + todo!() + } else { + let msg = format!( + "Expected aiohttp.ClientSession, got {}.{}", + module, class_name + ); + Err(PyTypeError::new_err(msg)) + } + } +} diff --git a/python/src/reader/mod.rs b/python/src/reader/mod.rs new file mode 100644 index 0000000..d6640bb --- /dev/null +++ b/python/src/reader/mod.rs @@ -0,0 +1 @@ +mod aiohttp;