Struct gio::Subprocess
source · [−]#[repr(transparent)]pub struct Subprocess { /* private fields */ }
Expand description
Subprocess
allows the creation of and interaction with child
processes.
Processes can be communicated with using standard GIO-style APIs (ie:
InputStream
, OutputStream
). There are GIO-style APIs to wait for
process termination (ie: cancellable and with an asynchronous
variant).
There is an API to force a process to terminate, as well as a race-free API for sending UNIX signals to a subprocess.
One major advantage that GIO brings over the core GLib library is
comprehensive API for asynchronous I/O, such
OutputStreamExt::splice_async()
. This makes GSubprocess
significantly more powerful and flexible than equivalent APIs in
some other languages such as the subprocess.py
included with Python. For example, using Subprocess
one could
create two child processes, reading standard output from the first,
processing it, and writing to the input stream of the second, all
without blocking the main loop.
A powerful communicate()
API is provided similar to the
communicate()
method of subprocess.py
. This enables very easy
interaction with a subprocess that has been opened with pipes.
Subprocess
defaults to tight control over the file descriptors open
in the child process, avoiding dangling-fd issues that are caused by
a simple fork()
/exec()
. The only open file descriptors in the
spawned process are ones that were explicitly specified by the
Subprocess
API (unless SubprocessFlags::INHERIT_FDS
was
specified).
Subprocess
will quickly reap all child processes as they exit,
avoiding “zombie processes” remaining around for long periods of
time. wait()
can be used to wait for this to happen,
but it will happen even without the call being explicitly made.
As a matter of principle, Subprocess
has no API that accepts
shell-style space-separated strings. It will, however, match the
typical shell behaviour of searching the PATH for executables that do
not contain a directory separator in their name. By default, the PATH
of the current process is used. You can specify
SubprocessFlags::SEARCH_PATH_FROM_ENVP
to use the PATH
of the
launcher environment instead.
Subprocess
attempts to have a very simple API for most uses (ie:
spawning a subprocess with arguments and support for most typical
kinds of input and output redirection). See g_subprocess_new()
. The
SubprocessLauncher
API is provided for more complicated cases
(advanced types of redirection, environment variable manipulation,
change of working directory, child setup functions, etc).
A typical use of Subprocess
will involve calling
g_subprocess_new()
, followed by wait_async()
or
wait()
. After the process exits, the status can be
checked using functions such as has_exited()
(which
are similar to the familiar WIFEXITED-style POSIX macros).
Implements
Implementations
sourceimpl Subprocess
impl Subprocess
sourcepub fn communicate_utf8_async<R: FnOnce(Result<(Option<GString>, Option<GString>), Error>) + 'static, C: IsA<Cancellable>>(
&self,
stdin_buf: Option<String>,
cancellable: Option<&C>,
callback: R
)
pub fn communicate_utf8_async<R: FnOnce(Result<(Option<GString>, Option<GString>), Error>) + 'static, C: IsA<Cancellable>>(
&self,
stdin_buf: Option<String>,
cancellable: Option<&C>,
callback: R
)
Asynchronous version of communicate_utf8()
. Complete
invocation with g_subprocess_communicate_utf8_finish()
.
stdin_buf
Input data, or None
cancellable
Cancellable
callback
Callback
pub fn communicate_utf8_future(
&self,
stdin_buf: Option<String>
) -> Pin<Box<dyn Future<Output = Result<(Option<GString>, Option<GString>), Error>> + 'static>>
sourceimpl Subprocess
impl Subprocess
sourcepub fn newv(
argv: &[&OsStr],
flags: SubprocessFlags
) -> Result<Subprocess, Error>
pub fn newv(
argv: &[&OsStr],
flags: SubprocessFlags
) -> Result<Subprocess, Error>
sourcepub fn communicate(
&self,
stdin_buf: Option<&Bytes>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(Option<Bytes>, Option<Bytes>), Error>
pub fn communicate(
&self,
stdin_buf: Option<&Bytes>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(Option<Bytes>, Option<Bytes>), Error>
Communicate with the subprocess until it terminates, and all input and output has been completed.
If stdin_buf
is given, the subprocess must have been created with
SubprocessFlags::STDIN_PIPE
. The given data is fed to the
stdin of the subprocess and the pipe is closed (ie: EOF).
At the same time (as not to cause blocking when dealing with large
amounts of data), if SubprocessFlags::STDOUT_PIPE
or
SubprocessFlags::STDERR_PIPE
were used, reads from those
streams. The data that was read is returned in stdout
and/or
the stderr
.
If the subprocess was created with SubprocessFlags::STDOUT_PIPE
,
stdout_buf
will contain the data read from stdout. Otherwise, for
subprocesses not created with SubprocessFlags::STDOUT_PIPE
,
stdout_buf
will be set to None
. Similar provisions apply to
stderr_buf
and SubprocessFlags::STDERR_PIPE
.
As usual, any output variable may be given as None
to ignore it.
If you desire the stdout and stderr data to be interleaved, create
the subprocess with SubprocessFlags::STDOUT_PIPE
and
SubprocessFlags::STDERR_MERGE
. The merged result will be returned
in stdout_buf
and stderr_buf
will be set to None
.
In case of any error (including cancellation), false
will be
returned with error
set. Some or all of the stdin data may have
been written. Any stdout or stderr data that has been read will be
discarded. None of the out variables (aside from error
) will have
been set to anything in particular and should not be inspected.
In the case that true
is returned, the subprocess has exited and the
exit status inspection APIs (eg: has_exited()
,
exit_status()
) may be used.
You should not attempt to use any of the subprocess pipes after starting this function, since they may be left in strange states, even if the operation was cancelled. You should especially not attempt to interact with the pipes while the operation is in progress (either from another thread or if using the asynchronous version).
stdin_buf
data to send to the stdin of the subprocess, or None
cancellable
Returns
true
if successful
stdout_buf
data read from the subprocess stdout
stderr_buf
data read from the subprocess stderr
sourcepub fn communicate_async<P: FnOnce(Result<(Option<Bytes>, Option<Bytes>), Error>) + 'static>(
&self,
stdin_buf: Option<&Bytes>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn communicate_async<P: FnOnce(Result<(Option<Bytes>, Option<Bytes>), Error>) + 'static>(
&self,
stdin_buf: Option<&Bytes>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Asynchronous version of communicate()
. Complete
invocation with g_subprocess_communicate_finish()
.
stdin_buf
Input data, or None
cancellable
Cancellable
callback
Callback
pub fn communicate_future(
&self,
stdin_buf: Option<&Bytes>
) -> Pin<Box_<dyn Future<Output = Result<(Option<Bytes>, Option<Bytes>), Error>> + 'static>>
sourcepub fn communicate_utf8(
&self,
stdin_buf: Option<&str>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(Option<GString>, Option<GString>), Error>
pub fn communicate_utf8(
&self,
stdin_buf: Option<&str>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(Option<GString>, Option<GString>), Error>
Like communicate()
, but validates the output of the
process as UTF-8, and returns it as a regular NUL terminated string.
On error, stdout_buf
and stderr_buf
will be set to undefined values and
should not be used.
stdin_buf
data to send to the stdin of the subprocess, or None
cancellable
Returns
stdout_buf
data read from the subprocess stdout
stderr_buf
data read from the subprocess stderr
sourcepub fn force_exit(&self)
pub fn force_exit(&self)
Use an operating-system specific method to attempt an immediate,
forceful termination of the process. There is no mechanism to
determine whether or not the request itself was successful;
however, you can use wait()
to monitor the status of
the process after calling this function.
On Unix, this function sends SIGKILL
.
sourcepub fn exit_status(&self) -> i32
pub fn exit_status(&self) -> i32
Check the exit status of the subprocess, given that it exited
normally. This is the value passed to the exit()
system call or the
return value from main.
This is equivalent to the system WEXITSTATUS macro.
It is an error to call this function before wait()
and
unless has_exited()
returned true
.
Returns
the exit status
sourcepub fn identifier(&self) -> Option<GString>
pub fn identifier(&self) -> Option<GString>
sourcepub fn has_exited(&self) -> bool
pub fn has_exited(&self) -> bool
sourcepub fn has_signaled(&self) -> bool
pub fn has_signaled(&self) -> bool
sourcepub fn status(&self) -> i32
pub fn status(&self) -> i32
Gets the raw status code of the process, as from waitpid()
.
This value has no particular meaning, but it can be used with the
macros defined by the system headers such as WIFEXITED. It can also
be used with g_spawn_check_wait_status()
.
It is more likely that you want to use has_exited()
followed by exit_status()
.
It is an error to call this function before wait()
has
returned.
Returns
the (meaningless) waitpid()
exit status from the kernel
sourcepub fn stderr_pipe(&self) -> Option<InputStream>
pub fn stderr_pipe(&self) -> Option<InputStream>
Gets the InputStream
from which to read the stderr output of
self
.
The process must have been created with SubprocessFlags::STDERR_PIPE
,
otherwise None
will be returned.
Returns
the stderr pipe
sourcepub fn stdin_pipe(&self) -> Option<OutputStream>
pub fn stdin_pipe(&self) -> Option<OutputStream>
Gets the OutputStream
that you can write to in order to give data
to the stdin of self
.
The process must have been created with SubprocessFlags::STDIN_PIPE
and
not SubprocessFlags::STDIN_INHERIT
, otherwise None
will be returned.
Returns
the stdout pipe
sourcepub fn stdout_pipe(&self) -> Option<InputStream>
pub fn stdout_pipe(&self) -> Option<InputStream>
Gets the InputStream
from which to read the stdout output of
self
.
The process must have been created with SubprocessFlags::STDOUT_PIPE
,
otherwise None
will be returned.
Returns
the stdout pipe
sourcepub fn is_successful(&self) -> bool
pub fn is_successful(&self) -> bool
Checks if the process was “successful”. A process is considered
successful if it exited cleanly with an exit status of 0, either by
way of the exit()
system call or return from main()
.
It is an error to call this function before wait()
has
returned.
Returns
true
if the process exited cleanly with a exit status of 0
sourcepub fn term_sig(&self) -> i32
pub fn term_sig(&self) -> i32
Get the signal number that caused the subprocess to terminate, given that it terminated due to a signal.
This is equivalent to the system WTERMSIG macro.
It is an error to call this function before wait()
and
unless has_signaled()
returned true
.
Returns
the signal causing termination
sourcepub fn send_signal(&self, signal_num: i32)
Available on non-Windows only.
pub fn send_signal(&self, signal_num: i32)
Sends the UNIX signal signal_num
to the subprocess, if it is still
running.
This API is race-free. If the subprocess has terminated, it will not be signalled.
This API is not available on Windows.
signal_num
the signal number to send
sourcepub fn wait(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
pub fn wait(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
Synchronously wait for the subprocess to terminate.
After the process terminates you can query its exit status with
functions such as has_exited()
and
exit_status()
.
This function does not fail in the case of the subprocess having
abnormal termination. See wait_check()
for that.
Cancelling cancellable
doesn’t kill the subprocess. Call
force_exit()
if it is desirable.
cancellable
Returns
sourcepub fn wait_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn wait_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Wait for the subprocess to terminate.
This is the asynchronous version of wait()
.
cancellable
a Cancellable
, or None
callback
a GAsyncReadyCallback
to call when the operation is complete
pub fn wait_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
sourcepub fn wait_check(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
pub fn wait_check(
&self,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
Combines wait()
with g_spawn_check_wait_status()
.
cancellable
Returns
true
on success, false
if process exited abnormally, or
cancellable
was cancelled
sourcepub fn wait_check_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
pub fn wait_check_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
Combines wait_async()
with g_spawn_check_wait_status()
.
This is the asynchronous version of wait_check()
.
cancellable
a Cancellable
, or None
callback
a GAsyncReadyCallback
to call when the operation is complete
pub fn wait_check_future(
&self
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
Trait Implementations
sourceimpl Clone for Subprocess
impl Clone for Subprocess
sourceimpl Debug for Subprocess
impl Debug for Subprocess
sourceimpl Display for Subprocess
impl Display for Subprocess
sourceimpl Hash for Subprocess
impl Hash for Subprocess
sourceimpl Ord for Subprocess
impl Ord for Subprocess
sourceimpl ParentClassIs for Subprocess
impl ParentClassIs for Subprocess
sourceimpl<OT: ObjectType> PartialEq<OT> for Subprocess
impl<OT: ObjectType> PartialEq<OT> for Subprocess
sourceimpl<OT: ObjectType> PartialOrd<OT> for Subprocess
impl<OT: ObjectType> PartialOrd<OT> for Subprocess
sourcefn partial_cmp(&self, other: &OT) -> Option<Ordering>
fn partial_cmp(&self, other: &OT) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl StaticType for Subprocess
impl StaticType for Subprocess
sourcefn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl Eq for Subprocess
impl IsA<Initable> for Subprocess
Auto Trait Implementations
impl RefUnwindSafe for Subprocess
impl !Send for Subprocess
impl !Sync for Subprocess
impl Unpin for Subprocess
impl UnwindSafe for Subprocess
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Cast for T where
T: ObjectType,
impl<T> Cast for T where
T: ObjectType,
sourcefn upcast<T>(self) -> T where
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> T where
T: ObjectType,
Self: IsA<T>,
Upcasts an object to a superclass or interface T
. Read more
sourcefn upcast_ref<T>(&self) -> &T where
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &T where
T: ObjectType,
Self: IsA<T>,
Upcasts an object to a reference of its superclass or interface T
. Read more
sourcefn downcast<T>(self) -> Result<T, Self> where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self> where
T: ObjectType,
Self: CanDowncast<T>,
Tries to downcast to a subclass or interface implementor T
. Read more
sourcefn downcast_ref<T>(&self) -> Option<&T> where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T> where
T: ObjectType,
Self: CanDowncast<T>,
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
sourcefn dynamic_cast<T>(self) -> Result<T, Self> where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self> where
T: ObjectType,
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
sourcefn dynamic_cast_ref<T>(&self) -> Option<&T> where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T> where
T: ObjectType,
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
sourceunsafe fn unsafe_cast<T>(self) -> T where
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> T where
T: ObjectType,
Casts to T
unconditionally. Read more
sourceunsafe fn unsafe_cast_ref<T>(&self) -> &T where
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &T where
T: ObjectType,
Casts to &T
unconditionally. Read more
sourceimpl<U> IsSubclassableExt for U where
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for U where
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>) where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>) where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
sourceimpl<T> ObjectExt for T where
T: ObjectType,
impl<T> ObjectExt for T where
T: ObjectType,
sourcefn is<U>(&self) -> bool where
U: StaticType,
fn is<U>(&self) -> bool where
U: StaticType,
Returns true
if the object is an instance of (can be cast to) T
.
sourcefn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
Returns the ObjectClass
of the object. Read more
sourcefn class_of<U>(&self) -> Option<&Class<U>> where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>> where
U: IsClass,
Returns the class of the object in the given type T
. Read more
sourcefn interface<U>(&self) -> Option<InterfaceRef<'_, U>> where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>> where
U: IsInterface,
Returns the interface T
of the object. Read more
sourcefn try_set_property<V>(
&self,
property_name: &str,
value: V
) -> Result<(), BoolError> where
V: ToValue,
fn try_set_property<V>(
&self,
property_name: &str,
value: V
) -> Result<(), BoolError> where
V: ToValue,
Similar to Self::set_property
but fails instead of panicking.
sourcefn set_property<V>(&self, property_name: &str, value: V) where
V: ToValue,
fn set_property<V>(&self, property_name: &str, value: V) where
V: ToValue,
Sets the property property_name
of the object to value value
. Read more
sourcefn try_set_property_from_value(
&self,
property_name: &str,
value: &Value
) -> Result<(), BoolError>
fn try_set_property_from_value(
&self,
property_name: &str,
value: &Value
) -> Result<(), BoolError>
Similar to Self::set_property
but fails instead of panicking.
sourcefn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
Sets the property property_name
of the object to value value
. Read more
sourcefn try_set_properties(
&self,
property_values: &[(&str, &dyn ToValue)]
) -> Result<(), BoolError>
fn try_set_properties(
&self,
property_values: &[(&str, &dyn ToValue)]
) -> Result<(), BoolError>
Similar to Self::set_properties
but fails instead of panicking.
sourcefn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
Sets multiple properties of the object at once. Read more
sourcefn try_set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
fn try_set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
Similar to Self::set_properties_from_value
but fails instead of panicking.
sourcefn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
Sets multiple properties of the object at once. Read more
sourcefn try_property<V>(&self, property_name: &str) -> Result<V, BoolError> where
V: 'static + for<'b> FromValue<'b>,
fn try_property<V>(&self, property_name: &str) -> Result<V, BoolError> where
V: 'static + for<'b> FromValue<'b>,
Similar to Self::property
but fails instead of panicking.
sourcefn property<V>(&self, property_name: &str) -> V where
V: 'static + for<'b> FromValue<'b>,
fn property<V>(&self, property_name: &str) -> V where
V: 'static + for<'b> FromValue<'b>,
Gets the property property_name
of the object and cast it to the type V. Read more
sourcefn try_property_value(&self, property_name: &str) -> Result<Value, BoolError>
fn try_property_value(&self, property_name: &str) -> Result<Value, BoolError>
Similar to Self::property_value
but fails instead of panicking.
sourcefn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
Gets the property property_name
of the object. Read more
sourcefn has_property(&self, property_name: &str, type_: Option<Type>) -> bool
fn has_property(&self, property_name: &str, type_: Option<Type>) -> bool
Check if the object has a property property_name
of the given type_
. Read more
sourcefn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
Get the type of the property property_name
of this object. Read more
sourcefn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
Get the ParamSpec
of the property property_name
of this object.
sourcefn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
Return all ParamSpec
of the properties of this object.
sourcefn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
Freeze all property notifications until the return guard object is dropped. Read more
sourceunsafe fn set_qdata<QD>(&self, key: Quark, value: QD) where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD) where
QD: 'static,
Set arbitrary data on this object with the given key
. Read more
sourceunsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>> where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>> where
QD: 'static,
Return previously set arbitrary data of this object with the given key
. Read more
sourceunsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD> where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD> where
QD: 'static,
Retrieve previously set arbitrary data of this object with the given key
. Read more
sourceunsafe fn set_data<QD>(&self, key: &str, value: QD) where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD) where
QD: 'static,
Set arbitrary data on this object with the given key
. Read more
sourceunsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>> where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>> where
QD: 'static,
Return previously set arbitrary data of this object with the given key
. Read more
sourceunsafe fn steal_data<QD>(&self, key: &str) -> Option<QD> where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD> where
QD: 'static,
Retrieve previously set arbitrary data of this object with the given key
. Read more
sourcefn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
Block a given signal handler. Read more
sourcefn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
Unblock a given signal handler.
sourcefn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
Stop emission of the currently emitted signal.
sourcefn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
sourcefn try_connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
fn try_connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
Similar to Self::connect
but fails instead of panicking.
sourcefn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
Connect to the signal signal_name
on this object. Read more
sourcefn try_connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
fn try_connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
Similar to Self::connect_id
but fails instead of panicking.
sourcefn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value> + Send + Sync,
Connect to the signal signal_id
on this object. Read more
sourcefn try_connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
fn try_connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_local
but fails instead of panicking.
sourcefn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_name
on this object. Read more
sourcefn try_connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
fn try_connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_local_id
but fails instead of panicking.
sourcefn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: 'static + for<'_> Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_id
on this object. Read more
sourceunsafe fn try_connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: for<'_> Fn(&[Value]) -> Option<Value>,
unsafe fn try_connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: for<'_> Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_unsafe
but fails instead of panicking.
sourceunsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: for<'_> Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerId where
F: for<'_> Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_name
on this object. Read more
sourceunsafe fn try_connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: for<'_> Fn(&[Value]) -> Option<Value>,
unsafe fn try_connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: for<'_> Fn(&[Value]) -> Option<Value>,
Similar to Self::connect_unsafe_id
but fails instead of panicking.
sourcefn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
fn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure
but fails instead of panicking.
sourcefn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
Connect a closure to the signal signal_name
on this object. Read more
sourcefn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
fn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure_id
but fails instead of panicking.
sourcefn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
Connect a closure to the signal signal_id
on this object. Read more
sourcefn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
Limits the lifetime of closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
Closure::invoke
. Read more
sourceunsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: for<'_> Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerId where
F: for<'_> Fn(&[Value]) -> Option<Value>,
Connect to the signal signal_id
on this object. Read more
sourcefn try_emit<R>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
fn try_emit<R>(
&self,
signal_id: SignalId,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit
but fails instead of panicking.
sourcefn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
Emit signal by signal id. Read more
sourcefn try_emit_with_values(
&self,
signal_id: SignalId,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_with_values(
&self,
signal_id: SignalId,
args: &[Value]
) -> Result<Option<Value>, BoolError>
Similar to Self::emit_with_values
but fails instead of panicking.
sourcefn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Same as Self::emit
but takes Value
for the arguments.
sourcefn try_emit_by_name<R>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
fn try_emit_by_name<R>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit_by_name
but fails instead of panicking.
sourcefn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
Emit signal by its name. Read more
sourcefn try_emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Result<Option<Value>, BoolError>
Similar to Self::emit_by_name_with_values
but fails instead of panicking.
sourcefn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
Emit signal by its name. Read more
sourcefn try_emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
fn try_emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit_by_name_with_details
but fails instead of panicking.
sourcefn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
Emit signal by its name with details. Read more
sourcefn try_emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
Similar to Self::emit_by_name_with_details_and_values
but fails instead of panicking.
sourcefn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
Emit signal by its name with details. Read more
sourcefn try_emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
fn try_emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit_with_details
but fails instead of panicking.
sourcefn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
Emit signal by signal id with details. Read more
sourcefn try_emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
fn try_emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Result<Option<Value>, BoolError>
Similar to Self::emit_with_details_and_values
but fails instead of panicking.
sourcefn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
Emit signal by signal id with details. Read more
sourcefn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
Disconnect a previously connected signal handler.
sourcefn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + for<'_, '_> Fn(&T, &ParamSpec) + Send + Sync,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + for<'_, '_> Fn(&T, &ParamSpec) + Send + Sync,
Connect to the notify
signal of the object. Read more
sourcefn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + for<'_, '_> Fn(&T, &ParamSpec),
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + for<'_, '_> Fn(&T, &ParamSpec),
Connect to the notify
signal of the object. Read more
sourceunsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: for<'_, '_> Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: for<'_, '_> Fn(&T, &ParamSpec),
Connect to the notify
signal of the object. Read more
sourcefn notify(&self, property_name: &str)
fn notify(&self, property_name: &str)
Notify that the given property has changed its value. Read more
sourcefn notify_by_pspec(&self, pspec: &ParamSpec)
fn notify_by_pspec(&self, pspec: &ParamSpec)
Notify that the given property has changed its value. Read more
sourcefn bind_property<O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a> where
O: ObjectType,
fn bind_property<O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a> where
O: ObjectType,
Bind property source_property
on this object to the target_property
on the target
object. Read more
sourceimpl<T> StaticTypeExt for T where
T: StaticType,
impl<T> StaticTypeExt for T where
T: StaticType,
sourcefn ensure_type()
fn ensure_type()
Ensures that the type has been registered with the type system.