@@ -11,7 +11,21 @@ pub enum PyCommentPosition {
1111 Special ,
1212}
1313
14- #[ pyclass( name = "Comment" ) ]
14+ #[ pymethods]
15+ impl PyCommentPosition {
16+ #[ getter]
17+ fn id ( & self ) -> PyResult < u8 > {
18+ Ok ( match self {
19+ PyCommentPosition :: Scroll => 0 ,
20+ PyCommentPosition :: Bottom => 1 ,
21+ PyCommentPosition :: Top => 2 ,
22+ PyCommentPosition :: Reversed => 3 ,
23+ PyCommentPosition :: Special => 4 ,
24+ } )
25+ }
26+ }
27+
28+ #[ pyclass( name = "Comment" , frozen) ]
1529pub struct PyComment {
1630 inner : comment:: Comment ,
1731}
@@ -25,57 +39,57 @@ impl PyComment {
2539#[ pymethods]
2640impl PyComment {
2741 #[ getter]
28- fn timeline ( & self ) -> PyResult < f64 > {
29- Ok ( self . inner . timeline )
42+ fn timeline ( & self ) -> f64 {
43+ self . inner . timeline
3044 }
3145
3246 #[ getter]
33- fn timestamp ( & self ) -> PyResult < u64 > {
34- Ok ( self . inner . timestamp )
47+ fn timestamp ( & self ) -> u64 {
48+ self . inner . timestamp
3549 }
3650
3751 #[ getter]
38- fn no ( & self ) -> PyResult < u64 > {
39- Ok ( self . inner . no )
52+ fn no ( & self ) -> u64 {
53+ self . inner . no
4054 }
4155
4256 #[ getter]
43- fn comment ( & self ) -> PyResult < String > {
44- Ok ( self . inner . comment . clone ( ) )
57+ fn comment ( & self ) -> & str {
58+ & self . inner . comment
4559 }
4660
4761 #[ getter]
48- fn pos ( & self ) -> PyResult < PyCommentPosition > {
49- Ok ( match self . inner . pos {
62+ fn pos ( & self ) -> PyCommentPosition {
63+ match self . inner . pos {
5064 comment:: CommentPosition :: Scroll => PyCommentPosition :: Scroll ,
5165 comment:: CommentPosition :: Bottom => PyCommentPosition :: Bottom ,
5266 comment:: CommentPosition :: Top => PyCommentPosition :: Top ,
5367 comment:: CommentPosition :: Reversed => PyCommentPosition :: Reversed ,
5468 comment:: CommentPosition :: Special => PyCommentPosition :: Special ,
55- } )
69+ }
5670 }
5771
5872 #[ getter]
59- fn color ( & self ) -> PyResult < u32 > {
60- Ok ( self . inner . color )
73+ fn color ( & self ) -> u32 {
74+ self . inner . color
6175 }
6276
6377 #[ getter]
64- fn size ( & self ) -> PyResult < f32 > {
65- Ok ( self . inner . size )
78+ fn size ( & self ) -> f32 {
79+ self . inner . size
6680 }
6781
6882 #[ getter]
69- fn height ( & self ) -> PyResult < f32 > {
70- Ok ( self . inner . height )
83+ fn height ( & self ) -> f32 {
84+ self . inner . height
7185 }
7286
7387 #[ getter]
74- fn width ( & self ) -> PyResult < f32 > {
75- Ok ( self . inner . width )
88+ fn width ( & self ) -> f32 {
89+ self . inner . width
7690 }
7791
78- fn __repr__ ( & self ) -> PyResult < String > {
79- Ok ( format ! ( "Comment({:?})" , self . inner) )
92+ fn __repr__ ( & self ) -> String {
93+ format ! ( "Comment({:?})" , self . inner)
8094 }
8195}
0 commit comments