Trait gio::prelude::PermissionExt
source · pub trait PermissionExt: 'static {
Show 13 methods
// Required methods
fn acquire(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>;
fn acquire_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
);
fn acquire_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>;
fn is_allowed(&self) -> bool;
fn can_acquire(&self) -> bool;
fn can_release(&self) -> bool;
fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool);
fn release(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>;
fn release_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
);
fn release_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>;
fn connect_allowed_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_can_acquire_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_can_release_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods§
sourcefn acquire(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn acquire( &self, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
Attempts to acquire the permission represented by self
.
The precise method by which this happens depends on the permission and the underlying authentication mechanism. A simple example is that a dialog may appear asking the user to enter their password.
You should check with can_acquire()
before calling
this function.
If the permission is acquired then true
is returned. Otherwise,
false
is returned and error
is set appropriately.
This call is blocking, likely for a very long time (in the case that
user interaction is required). See acquire_async()
for
the non-blocking version.
cancellable
a Cancellable
, or None
Returns
true
if the permission was successfully acquired
sourcefn acquire_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn acquire_async<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Attempts to acquire the permission represented by self
.
This is the first half of the asynchronous version of
acquire()
.
cancellable
a Cancellable
, or None
callback
the GAsyncReadyCallback
to call when done
fn acquire_future( &self ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcefn is_allowed(&self) -> bool
fn is_allowed(&self) -> bool
sourcefn can_acquire(&self) -> bool
fn can_acquire(&self) -> bool
sourcefn can_release(&self) -> bool
fn can_release(&self) -> bool
sourcefn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool)
fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool)
This function is called by the Permission
implementation to update
the properties of the permission. You should never call this
function except from a Permission
implementation.
GObject notify signals are generated, as appropriate.
allowed
the new value for the ‘allowed’ property
can_acquire
the new value for the ‘can-acquire’ property
can_release
the new value for the ‘can-release’ property
sourcefn release(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn release( &self, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
Attempts to release the permission represented by self
.
The precise method by which this happens depends on the permission and the underlying authentication mechanism. In most cases the permission will be dropped immediately without further action.
You should check with can_release()
before calling
this function.
If the permission is released then true
is returned. Otherwise,
false
is returned and error
is set appropriately.
This call is blocking, likely for a very long time (in the case that
user interaction is required). See release_async()
for
the non-blocking version.
cancellable
a Cancellable
, or None
Returns
true
if the permission was successfully released
sourcefn release_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn release_async<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
Attempts to release the permission represented by self
.
This is the first half of the asynchronous version of
release()
.
cancellable
a Cancellable
, or None
callback
the GAsyncReadyCallback
to call when done