5
5
use serde:: Serialize ;
6
6
7
7
use crate :: plugin:: { Builder , TauriPlugin } ;
8
- use crate :: { command, image:: Image , AppHandle , Manager , ResourceId , Runtime } ;
8
+ use crate :: Manager ;
9
+ use crate :: { command, image:: Image , ResourceId , Runtime , Webview } ;
9
10
10
11
#[ command( root = "crate" ) ]
11
12
fn new < R : Runtime > (
12
- app : AppHandle < R > ,
13
+ webview : Webview < R > ,
13
14
rgba : Vec < u8 > ,
14
15
width : u32 ,
15
16
height : u32 ,
16
17
) -> crate :: Result < ResourceId > {
17
18
let image = Image :: new_owned ( rgba, width, height) ;
18
- let mut resources_table = app . resources_table ( ) ;
19
+ let mut resources_table = webview . resources_table ( ) ;
19
20
let rid = resources_table. add ( image) ;
20
21
Ok ( rid)
21
22
}
22
23
23
24
#[ cfg( any( feature = "image-ico" , feature = "image-png" ) ) ]
24
25
#[ command( root = "crate" ) ]
25
- fn from_bytes < R : Runtime > ( app : AppHandle < R > , bytes : Vec < u8 > ) -> crate :: Result < ResourceId > {
26
+ fn from_bytes < R : Runtime > ( webview : Webview < R > , bytes : Vec < u8 > ) -> crate :: Result < ResourceId > {
26
27
let image = Image :: from_bytes ( & bytes) ?. to_owned ( ) ;
27
- let mut resources_table = app . resources_table ( ) ;
28
+ let mut resources_table = webview . resources_table ( ) ;
28
29
let rid = resources_table. add ( image) ;
29
30
Ok ( rid)
30
31
}
@@ -37,9 +38,12 @@ fn from_bytes() -> std::result::Result<(), &'static str> {
37
38
38
39
#[ cfg( any( feature = "image-ico" , feature = "image-png" ) ) ]
39
40
#[ command( root = "crate" ) ]
40
- fn from_path < R : Runtime > ( app : AppHandle < R > , path : std:: path:: PathBuf ) -> crate :: Result < ResourceId > {
41
+ fn from_path < R : Runtime > (
42
+ webview : Webview < R > ,
43
+ path : std:: path:: PathBuf ,
44
+ ) -> crate :: Result < ResourceId > {
41
45
let image = Image :: from_path ( path) ?. to_owned ( ) ;
42
- let mut resources_table = app . resources_table ( ) ;
46
+ let mut resources_table = webview . resources_table ( ) ;
43
47
let rid = resources_table. add ( image) ;
44
48
Ok ( rid)
45
49
}
@@ -51,8 +55,8 @@ fn from_path() -> std::result::Result<(), &'static str> {
51
55
}
52
56
53
57
#[ command( root = "crate" ) ]
54
- fn rgba < R : Runtime > ( app : AppHandle < R > , rid : ResourceId ) -> crate :: Result < Vec < u8 > > {
55
- let resources_table = app . resources_table ( ) ;
58
+ fn rgba < R : Runtime > ( webview : Webview < R > , rid : ResourceId ) -> crate :: Result < Vec < u8 > > {
59
+ let resources_table = webview . resources_table ( ) ;
56
60
let image = resources_table. get :: < Image < ' _ > > ( rid) ?;
57
61
Ok ( image. rgba ( ) . to_vec ( ) )
58
62
}
@@ -64,8 +68,8 @@ struct Size {
64
68
}
65
69
66
70
#[ command( root = "crate" ) ]
67
- fn size < R : Runtime > ( app : AppHandle < R > , rid : ResourceId ) -> crate :: Result < Size > {
68
- let resources_table = app . resources_table ( ) ;
71
+ fn size < R : Runtime > ( webview : Webview < R > , rid : ResourceId ) -> crate :: Result < Size > {
72
+ let resources_table = webview . resources_table ( ) ;
69
73
let image = resources_table. get :: < Image < ' _ > > ( rid) ?;
70
74
Ok ( Size {
71
75
width : image. width ( ) ,
0 commit comments