44// License, v. 2.0. If a copy of the MPL was not distributed with this
55// file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
7- use crate :: be:: Error as BeError ;
8- use crate :: be:: { BootEnvironment , Client , Label , MountMode , Root , Snapshot } ;
9- use event_listener:: Listener ;
107use std:: collections:: { BTreeMap , HashMap , HashSet } ;
118use std:: path:: { Path , PathBuf } ;
129use std:: str:: FromStr ;
1310use std:: sync:: { Arc , Mutex , RwLock } ;
11+
12+ use event_listener:: Listener ;
1413use tracing;
1514use tracing_subscriber;
1615use zbus:: object_server:: SignalEmitter ;
1716use zbus:: { blocking, interface} ;
1817use zvariant:: ObjectPath ;
1918
19+ use crate :: be:: { BootEnvironment , Client , Error , Label , MountMode , Root , Snapshot } ;
20+
2021// D-Bus service constants
2122const SERVICE_NAME : & str = "ca.kamacite.BootEnvironments1" ;
2223const MANAGER_INTERFACE : & str = "ca.kamacite.BootEnvironmentManager" ;
@@ -42,7 +43,7 @@ impl ClientProxy {
4243 /// service or D-Bus itself is unavailable.
4344 ///
4445 /// This will also ping the D-Bus service to check if it's available.
45- pub fn new ( ) -> Result < Self , BeError > {
46+ pub fn new ( ) -> Result < Self , Error > {
4647 // This is equivalent to async_io::block_on(zbus::Connection::system())?.
4748 let connection = zbus:: blocking:: Connection :: system ( ) ?;
4849 // Look up the ActiveRoot property, which is an indirect way to check if
@@ -75,7 +76,7 @@ impl Client for ClientProxy {
7576 source : Option < & Label > ,
7677 properties : & [ String ] ,
7778 root : Option < & Root > ,
78- ) -> Result < ( ) , BeError > {
79+ ) -> Result < ( ) , Error > {
7980 let desc = description. unwrap_or ( "" ) ;
8081 let src = source. map ( |label| label. to_string ( ) ) . unwrap_or_default ( ) ;
8182 let props: Vec < String > = properties. to_vec ( ) ;
@@ -103,7 +104,7 @@ impl Client for ClientProxy {
103104 host_id : Option < & str > ,
104105 properties : & [ String ] ,
105106 root : Option < & Root > ,
106- ) -> Result < ( ) , BeError > {
107+ ) -> Result < ( ) , Error > {
107108 let desc = description. unwrap_or ( "" ) ;
108109 let hid = host_id. unwrap_or ( "" ) ;
109110 let props: Vec < String > = properties. to_vec ( ) ;
@@ -130,7 +131,7 @@ impl Client for ClientProxy {
130131 force_unmount : bool ,
131132 snapshots : bool ,
132133 root : Option < & Root > ,
133- ) -> Result < ( ) , BeError > {
134+ ) -> Result < ( ) , Error > {
134135 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
135136 match target {
136137 Label :: Name ( name) => self . connection . call_method (
@@ -157,7 +158,7 @@ impl Client for ClientProxy {
157158 mountpoint : Option < & Path > ,
158159 mode : MountMode ,
159160 root : Option < & Root > ,
160- ) -> Result < PathBuf , BeError > {
161+ ) -> Result < PathBuf , Error > {
161162 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
162163 let read_only = match mode {
163164 MountMode :: ReadOnly => true ,
@@ -183,7 +184,7 @@ impl Client for ClientProxy {
183184 be_name : & str ,
184185 force : bool ,
185186 root : Option < & Root > ,
186- ) -> Result < Option < PathBuf > , BeError > {
187+ ) -> Result < Option < PathBuf > , Error > {
187188 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
188189 let result: String = self
189190 . connection
@@ -204,12 +205,12 @@ impl Client for ClientProxy {
204205 }
205206 }
206207
207- fn hostid ( & self , _be_name : & str , _root : Option < & Root > ) -> Result < Option < u32 > , BeError > {
208+ fn hostid ( & self , _be_name : & str , _root : Option < & Root > ) -> Result < Option < u32 > , Error > {
208209 // TODO: Decide whether to implement this.
209210 Ok ( None )
210211 }
211212
212- fn rename ( & self , be_name : & str , new_name : & str , root : Option < & Root > ) -> Result < ( ) , BeError > {
213+ fn rename ( & self , be_name : & str , new_name : & str , root : Option < & Root > ) -> Result < ( ) , Error > {
213214 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
214215 self . connection . call_method (
215216 Some ( SERVICE_NAME ) ,
@@ -221,7 +222,7 @@ impl Client for ClientProxy {
221222 Ok ( ( ) )
222223 }
223224
224- fn activate ( & self , be_name : & str , temporary : bool , root : Option < & Root > ) -> Result < ( ) , BeError > {
225+ fn activate ( & self , be_name : & str , temporary : bool , root : Option < & Root > ) -> Result < ( ) , Error > {
225226 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
226227 self . connection . call_method (
227228 Some ( SERVICE_NAME ) ,
@@ -233,7 +234,7 @@ impl Client for ClientProxy {
233234 Ok ( ( ) )
234235 }
235236
236- fn clear_boot_once ( & self , root : Option < & Root > ) -> Result < ( ) , BeError > {
237+ fn clear_boot_once ( & self , root : Option < & Root > ) -> Result < ( ) , Error > {
237238 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
238239 self . connection . call_method (
239240 Some ( SERVICE_NAME ) ,
@@ -245,7 +246,7 @@ impl Client for ClientProxy {
245246 Ok ( ( ) )
246247 }
247248
248- fn rollback ( & self , be_name : & str , snapshot : & str , root : Option < & Root > ) -> Result < ( ) , BeError > {
249+ fn rollback ( & self , be_name : & str , snapshot : & str , root : Option < & Root > ) -> Result < ( ) , Error > {
249250 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
250251 self . connection . call_method (
251252 Some ( SERVICE_NAME ) ,
@@ -257,10 +258,10 @@ impl Client for ClientProxy {
257258 Ok ( ( ) )
258259 }
259260
260- fn get_boot_environments ( & self , root : Option < & Root > ) -> Result < Vec < BootEnvironment > , BeError > {
261+ fn get_boot_environments ( & self , root : Option < & Root > ) -> Result < Vec < BootEnvironment > , Error > {
261262 let root = match root. or ( self . active_root . as_ref ( ) ) {
262263 Some ( root) => root,
263- None => return Err ( BeError :: NoActiveBootEnvironment ) ,
264+ None => return Err ( Error :: NoActiveBootEnvironment ) ,
264265 } ;
265266 let body = self
266267 . connection
@@ -287,7 +288,7 @@ impl Client for ClientProxy {
287288 Ok ( boot_environments)
288289 }
289290
290- fn get_snapshots ( & self , be_name : & str , root : Option < & Root > ) -> Result < Vec < Snapshot > , BeError > {
291+ fn get_snapshots ( & self , be_name : & str , root : Option < & Root > ) -> Result < Vec < Snapshot > , Error > {
291292 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
292293 let snapshots_data: Vec < ( String , Root , String , u64 , i64 ) > = self
293294 . connection
@@ -324,7 +325,7 @@ impl Client for ClientProxy {
324325 source : Option < & Label > ,
325326 description : Option < & str > ,
326327 root : Option < & Root > ,
327- ) -> Result < String , BeError > {
328+ ) -> Result < String , Error > {
328329 let src = source. map ( |label| label. to_string ( ) ) . unwrap_or_default ( ) ;
329330 let desc = description. unwrap_or ( "" ) ;
330331 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
@@ -342,7 +343,7 @@ impl Client for ClientProxy {
342343 Ok ( result)
343344 }
344345
345- fn init ( & self , pool : & str ) -> Result < ( ) , BeError > {
346+ fn init ( & self , pool : & str ) -> Result < ( ) , Error > {
346347 let _result: ( ) = self
347348 . connection
348349 . call_method (
@@ -362,7 +363,7 @@ impl Client for ClientProxy {
362363 target : & Label ,
363364 description : & str ,
364365 root : Option < & Root > ,
365- ) -> Result < ( ) , BeError > {
366+ ) -> Result < ( ) , Error > {
366367 let target_str = target. to_string ( ) ;
367368 let beroot = root. map ( |r| r. as_str ( ) ) . unwrap_or_default ( ) ;
368369 self . connection . call_method (
@@ -894,7 +895,7 @@ impl<T: Client + 'static> BootEnvironmentManager<T> {
894895 . into_iter ( )
895896 . find ( |be| be. name == name)
896897 . map ( |be| be. guid )
897- . ok_or_else ( || BeError :: not_found ( name) ) ?;
898+ . ok_or_else ( || Error :: not_found ( name) ) ?;
898899
899900 tracing:: info!(
900901 name,
@@ -934,7 +935,7 @@ impl<T: Client + 'static> BootEnvironmentManager<T> {
934935 . into_iter ( )
935936 . find ( |be| be. name == name)
936937 . map ( |be| be. guid )
937- . ok_or_else ( || BeError :: not_found ( name) ) ?;
938+ . ok_or_else ( || Error :: not_found ( name) ) ?;
938939
939940 tracing:: info!( name, description = desc, "Created empty boot environment" ) ;
940941 self . refresh ( conn. object_server ( ) ) . await ?;
0 commit comments