Skip to content

Commit 8ed15f0

Browse files
committed
aiohttp backend
1 parent 35eaf11 commit 8ed15f0

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

python/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod decoder;
44
mod enums;
55
mod geo;
66
mod ifd;
7+
mod reader;
78
mod thread_pool;
89
mod tiff;
910
mod tile;

python/src/reader/aiohttp.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use pyo3::exceptions::PyTypeError;
2+
use pyo3::intern;
3+
use pyo3::prelude::*;
4+
use pyo3::pybacked::PyBackedStr;
5+
6+
struct AiohttpSession(PyObject);
7+
8+
impl<'py> FromPyObject<'py> for AiohttpSession {
9+
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
10+
let py = ob.py();
11+
let cls = ob.getattr(intern!(py, "__class__"))?;
12+
let module = cls
13+
.getattr(intern!(py, "__module__"))?
14+
.extract::<PyBackedStr>()?;
15+
let class_name = cls
16+
.getattr(intern!(py, "__name__"))?
17+
.extract::<PyBackedStr>()?;
18+
if module.starts_with("aiohttp") && class_name == "ClientSession" {
19+
todo!()
20+
} else {
21+
let msg = format!(
22+
"Expected aiohttp.ClientSession, got {}.{}",
23+
module, class_name
24+
);
25+
Err(PyTypeError::new_err(msg))
26+
}
27+
}
28+
}

python/src/reader/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod aiohttp;

0 commit comments

Comments
 (0)