55use serde:: Serialize ;
66
77use 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 } ;
910
1011#[ command( root = "crate" ) ]
1112fn new < R : Runtime > (
12- app : AppHandle < R > ,
13+ webview : Webview < R > ,
1314 rgba : Vec < u8 > ,
1415 width : u32 ,
1516 height : u32 ,
1617) -> crate :: Result < ResourceId > {
1718 let image = Image :: new_owned ( rgba, width, height) ;
18- let mut resources_table = app . resources_table ( ) ;
19+ let mut resources_table = webview . resources_table ( ) ;
1920 let rid = resources_table. add ( image) ;
2021 Ok ( rid)
2122}
2223
2324#[ cfg( any( feature = "image-ico" , feature = "image-png" ) ) ]
2425#[ 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 > {
2627 let image = Image :: from_bytes ( & bytes) ?. to_owned ( ) ;
27- let mut resources_table = app . resources_table ( ) ;
28+ let mut resources_table = webview . resources_table ( ) ;
2829 let rid = resources_table. add ( image) ;
2930 Ok ( rid)
3031}
@@ -37,9 +38,12 @@ fn from_bytes() -> std::result::Result<(), &'static str> {
3738
3839#[ cfg( any( feature = "image-ico" , feature = "image-png" ) ) ]
3940#[ 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 > {
4145 let image = Image :: from_path ( path) ?. to_owned ( ) ;
42- let mut resources_table = app . resources_table ( ) ;
46+ let mut resources_table = webview . resources_table ( ) ;
4347 let rid = resources_table. add ( image) ;
4448 Ok ( rid)
4549}
@@ -51,8 +55,8 @@ fn from_path() -> std::result::Result<(), &'static str> {
5155}
5256
5357#[ 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 ( ) ;
5660 let image = resources_table. get :: < Image < ' _ > > ( rid) ?;
5761 Ok ( image. rgba ( ) . to_vec ( ) )
5862}
@@ -64,8 +68,8 @@ struct Size {
6468}
6569
6670#[ 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 ( ) ;
6973 let image = resources_table. get :: < Image < ' _ > > ( rid) ?;
7074 Ok ( Size {
7175 width : image. width ( ) ,
0 commit comments