File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1
1
from collections .abc import Buffer
2
2
3
+ from .enums import CompressionMethod
3
4
from ._decoder import DecoderRegistry
4
5
from ._thread_pool import ThreadPool
5
6
6
7
class Tile :
8
+ @property
9
+ def x (self ) -> int : ...
10
+ @property
11
+ def y (self ) -> int : ...
12
+ @property
13
+ def compressed_bytes (self ) -> Buffer : ...
14
+ @property
15
+ def compression_method (self ) -> CompressionMethod : ...
7
16
async def decode (
8
17
self ,
9
18
* ,
Original file line number Diff line number Diff line change 1
1
use async_tiff:: Tile ;
2
+ use pyo3:: exceptions:: PyValueError ;
2
3
use pyo3:: prelude:: * ;
3
4
use pyo3_async_runtimes:: tokio:: future_into_py;
4
5
use pyo3_bytes:: PyBytes ;
5
6
use tokio_rayon:: AsyncThreadPool ;
6
7
7
8
use crate :: decoder:: get_default_decoder_registry;
9
+ use crate :: enums:: PyCompressionMethod ;
8
10
use crate :: thread_pool:: { get_default_pool, PyThreadPool } ;
9
11
use crate :: PyDecoderRegistry ;
10
12
@@ -13,6 +15,39 @@ pub(crate) struct PyTile(Option<Tile>);
13
15
14
16
#[ pymethods]
15
17
impl PyTile {
18
+ #[ getter]
19
+ fn x ( & self ) -> PyResult < usize > {
20
+ self . 0
21
+ . as_ref ( )
22
+ . ok_or ( PyValueError :: new_err ( "Tile has been consumed" ) )
23
+ . map ( |t| t. x ( ) )
24
+ }
25
+
26
+ #[ getter]
27
+ fn y ( & self ) -> PyResult < usize > {
28
+ self . 0
29
+ . as_ref ( )
30
+ . ok_or ( PyValueError :: new_err ( "Tile has been consumed" ) )
31
+ . map ( |t| t. y ( ) )
32
+ }
33
+
34
+ #[ getter]
35
+ fn compressed_bytes ( & self ) -> PyResult < PyBytes > {
36
+ let tile = self
37
+ . 0
38
+ . as_ref ( )
39
+ . ok_or ( PyValueError :: new_err ( "Tile has been consumed" ) ) ?;
40
+ Ok ( tile. compressed_bytes ( ) . clone ( ) . into ( ) )
41
+ }
42
+
43
+ #[ getter]
44
+ fn compression_method ( & self ) -> PyResult < PyCompressionMethod > {
45
+ self . 0
46
+ . as_ref ( )
47
+ . ok_or ( PyValueError :: new_err ( "Tile has been consumed" ) )
48
+ . map ( |t| t. compression_method ( ) . into ( ) )
49
+ }
50
+
16
51
#[ pyo3( signature = ( * , decoder_registry=None , pool=None ) ) ]
17
52
fn decode_async (
18
53
& mut self ,
You can’t perform that action at this time.
0 commit comments