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 11from collections .abc import Buffer
22
3+ from .enums import CompressionMethod
34from ._decoder import DecoderRegistry
45from ._thread_pool import ThreadPool
56
67class 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 : ...
716 async def decode (
817 self ,
918 * ,
Original file line number Diff line number Diff line change 11use async_tiff:: Tile ;
2+ use pyo3:: exceptions:: PyValueError ;
23use pyo3:: prelude:: * ;
34use pyo3_async_runtimes:: tokio:: future_into_py;
45use pyo3_bytes:: PyBytes ;
56use tokio_rayon:: AsyncThreadPool ;
67
78use crate :: decoder:: get_default_decoder_registry;
9+ use crate :: enums:: PyCompressionMethod ;
810use crate :: thread_pool:: { get_default_pool, PyThreadPool } ;
911use crate :: PyDecoderRegistry ;
1012
@@ -13,6 +15,39 @@ pub(crate) struct PyTile(Option<Tile>);
1315
1416#[ pymethods]
1517impl 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+
1651 #[ pyo3( signature = ( * , decoder_registry=None , pool=None ) ) ]
1752 fn decode_async (
1853 & mut self ,
You can’t perform that action at this time.
0 commit comments