gio/
application_command_line.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{prelude::*, translate::*, ExitCode};
4
5use crate::{ffi, ApplicationCommandLine};
6
7pub trait ApplicationCommandLineExtManual: IsA<ApplicationCommandLine> {
8    #[doc(alias = "g_application_command_line_get_exit_status")]
9    #[doc(alias = "get_exit_status")]
10    fn exit_code(&self) -> ExitCode {
11        let status = unsafe {
12            ffi::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0)
13        };
14
15        ExitCode::try_from(status).unwrap()
16    }
17
18    #[doc(alias = "g_application_command_line_set_exit_status")]
19    #[doc(alias = "set_exit_status")]
20    fn set_exit_code(&self, exit_code: ExitCode) {
21        let status = i32::from(exit_code.get());
22
23        unsafe {
24            ffi::g_application_command_line_set_exit_status(self.as_ref().to_glib_none().0, status);
25        }
26    }
27}
28
29impl<O: IsA<ApplicationCommandLine>> ApplicationCommandLineExtManual for O {}