Debian Codegraph @

_transport_rs/src/gio.rs

raw
1 use crate::{map_transport_err_to_py_err, Transport};
2 use pyo3::prelude::*;
3
4 #[pyclass(extends=Transport, subclass)]
5 pub(crate) struct GioTransport {}
6
7 #[pymethods]
8 impl GioTransport {
9 #[new]
10 #[pyo3(signature = (base, _from_transport=None))]
11 fn new(base: &str, _from_transport: Option<Py<PyAny>>) -> PyResult<(Self, Transport)> {
12 let _ = _from_transport;
13 let rust = dromedary::gio::GioTransport::new(base)
14 .map_err(|e| map_transport_err_to_py_err(e, None, None))?;
15 Ok((GioTransport {}, Transport(Box::new(rust))))
16 }
17
18 #[pyo3(signature = (offset=None))]
19 fn clone<'a>(
20 slf: PyRef<'a, Self>,
21 py: Python<'a>,
22 offset: Option<String>,
23 ) -> PyResult<Bound<'a, GioTransport>> {
24 let super_ = slf.as_ref();
25 let inner = super_
26 .0
27 .clone(offset.as_deref())
28 .map_err(|e| map_transport_err_to_py_err(e, None, None))?;
29 let init = PyClassInitializer::from(Transport(inner)).add_subclass(GioTransport {});
30 Bound::new(py, init)
31 }
32 }
33
34 pub(crate) fn register(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
35 m.add_class::<GioTransport>()?;
36 Ok(())
37 }