Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Dex.aio_read(aio_context, fd, offset)¶
- Parameters:
aio_context (
Dex.AioContextorNone) –fd (
int) –offset (
int) – the positioned offset within fd to read from
- Returns:
a future that will resolve when the read completes or rejects with error.
- Return type:
(
Dex.Future, buffer:bytes)
An asynchronous
pread()wrapper.Generally you want to provide
NULLfor the aio_context as that will get the default aio context for your scheduler.
- Dex.aio_write(aio_context, fd, buffer, offset)¶
- Parameters:
aio_context (
Dex.AioContextorNone) –fd (
int) –buffer (
bytes) –offset (
int) – the positioned offset within fd to write at
- Returns:
a future that will resolve when the write completes or rejects with error.
- Return type:
An asynchronous
pwrite()wrapper.Generally you want to provide
NULLfor the aio_context as that will get the default aio context for your scheduler.
- Dex.async_initable_init(initable, io_priority)¶
- Parameters:
initable (
Gio.AsyncInitable) – a [iface`Gio`.AsyncInitable]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to the initable instance or rejects with error.
- Return type:
A helper for [method`Gio`.AsyncInitable.init_async].
New in version 1.0.
- Dex.bus_get(bus_type)¶
- Parameters:
bus_type (
Gio.BusType) – the [enum`Gio`.BusType]- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.DBusConnection] or rejects with error.
- Return type:
Wrapper for [func`Gio`.bus_get].
New in version 0.4.
- Dex.bus_own_name_on_connection(connection, name, flags)¶
- Parameters:
connection (
Gio.DBusConnection) – The [class`Gio`.DBusConnection] to own a name on.name (
str) – The well-known name to own.flags (
Gio.BusNameOwnerFlags) – a set of flags with ownership options.
- Returns:
- out_name_acquired_future:
a location for the name acquired future
- out_name_lost_future:
a location for the name lost future
- Return type:
(out_name_acquired_future:
Dex.Future, out_name_lost_future:Dex.Future)
Wrapper for [func`Gio`.bus_own_name].
Asks the D-Bus broker to own the well-known name name on the connection connection.
out_name_acquired_future is a future that awaits owning the name and either resolves to true, or rejects with an error.
out_name_lost_future is a future that rejects when the name was lost.
If either future is canceled, the name will be unowned.
New in version 1.1.
- Dex.data_input_stream_read_line(stream, io_priority)¶
- Parameters:
stream (
Gio.DataInputStream) – a [class`Gio`.DataInputStream]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a string containing the line (without the line terminator), or
Noneif the end of the stream is reached.- Return type:
Reads a line from the data input stream.
Wraps [method`Gio`.DataInputStream.read_line_async].
New in version 1.1.
- Dex.dbus_connection_call(connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec)¶
- Parameters:
connection (
Gio.DBusConnection) – a [class`Gio`.DBusConnection]bus_name (
strorNone) – a unique or well-known bus name orNoneif connection is not a message bus connectionobject_path (
str) – path of remote objectinterface_name (
str) – D-Bus interface to invoke method onmethod_name (
str) – the name of the method to invokeparameters (
GLib.VariantorNone) – a [struct`GLib`.Variant] tuple with parameters for the method orNoneif not passing parametersreply_type (
GLib.VariantTypeorNone) – the expected type of the reply (which will be a tuple), orNoneflags (
Gio.DBusCallFlags) – flags from the [flags`Gio`.DBusCallFlags] enumerationtimeout_msec (
int) – the timeout in milliseconds, -1 to use the default timeout orGObject.G_MAXINTfor no timeout
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.Variant] or rejects with error.
- Return type:
Wrapper for [method`Gio`.DBusConnection.call].
New in version 0.4.
- Dex.dbus_connection_call_with_unix_fd_list(connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, fd_list)¶
- Parameters:
connection (
Gio.DBusConnection) – a [class`Gio`.DBusConnection]bus_name (
strorNone) – a unique or well-known bus name orNoneif connection is not a message bus connectionobject_path (
str) – path of remote objectinterface_name (
str) – D-Bus interface to invoke method onmethod_name (
str) – the name of the method to invokeparameters (
GLib.VariantorNone) – a [struct`GLib`.Variant] tuple with parameters for the method orNoneif not passing parametersreply_type (
GLib.VariantTypeorNone) – the expected type of the reply (which will be a tuple), orNoneflags (
Gio.DBusCallFlags) – flags from the [flags`Gio`.DBusCallFlags] enumerationtimeout_msec (
int) – the timeout in milliseconds, -1 to use the default timeout orGObject.G_MAXINTfor no timeoutfd_list (
Gio.UnixFDListorNone) – a [class`Gio`.UnixFDList]
- Returns:
a [class`Dex`.FutureSet] that resolves to a [struct`GLib`.Variant].
The [class`Dex`.Future] containing the resulting [class`Gio`.UnixFDList] can be retrieved with [method`Dex`.FutureSet.get_future_at] with an index of 1.
- Return type:
Wrapper for [method`Gio`.DBusConnection.call_with_unix_fd_list].
New in version 0.4.
- Dex.dbus_connection_close(connection)¶
- Parameters:
connection (
Gio.DBusConnection) – a [class`Gio`.DBusConnection]- Returns:
a [class`Dex`.Future] that resolves to
trueor rejects with error.- Return type:
Asynchronously closes a connection.
New in version 1.0.
- Dex.dbus_connection_send_message_with_reply(connection, message, flags, timeout_msec)¶
- Parameters:
connection (
Gio.DBusConnection) – a [class`Gio`.DBusConnection]message (
Gio.DBusMessage) – a [class`Gio`.DBusMessage]flags (
Gio.DBusSendMessageFlags) – a set of [flags`Gio`.DBusSendMessageFlags]timeout_msec (
int) – timeout in milliseconds, or -1 for default, orGObject.G_MAXINTfor no timeout.
- Returns:
a [class`Dex`.Future] that will resolve to a [class`Gio`.DBusMessage] or reject with failure.
- out_serial:
a location for the message serial number
- Return type:
(
Dex.Future, out_serial:int)
Wrapper for [method`Gio`.DBusConnection.send_message_with_reply].
New in version 0.4.
- Dex.fd_watch(fd, events)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to the revents value when events is satisfied.
- Return type:
Creates a new
GLib.Sourcethat will fire when events is satisfied.This is primarily useful when integrating with legacy systems on a fiber.
New in version 1.1.
- Dex.file_copy(source, destination, flags, io_priority)¶
- Parameters:
source (
Gio.File) – a [iface`Gio`.File]destination (
Gio.File) – a [iface`Gio`.File]flags (
Gio.FileCopyFlags) – a set of [flags`Gio`.FileCopyFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to true if successful otherwise rejects with error.
- Return type:
Asynchronously copies a file and returns a [class`Dex`.Future] which can be observed for the result.
- Dex.file_create(file, flags, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]flags (
Gio.FileCreateFlags) – flags for creating the fileio_priority (
int) – priority for the IO operation
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileOutputStream] or rejects with error.
- Return type:
Wraps [method`Gio`.File.create] as a [class`Dex`.Future].
New in version 1.1.
- Dex.file_delete(file, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to true or rejects with error.
- Return type:
Asynchronously deletes a file and returns a [class`Dex`.Future] which can be observed for the result.
- Dex.file_enumerate_children(file, attributes, flags, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]attributes (
str) – an attribute query string (see: GFile documentation)flags (
Gio.FileQueryInfoFlags) – a set of [flags`Gio`.FileQueryInfoFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileEnumerator] or rejects with error.
- Return type:
- Dex.file_enumerator_next_files(file_enumerator, num_files, io_priority)¶
- Parameters:
file_enumerator (
Gio.FileEnumerator) – a [class`Gio`.FileEnumerator]num_files (
int) – the number of filesio_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.List] of [class`Gio`.FileInfo]
- Return type:
Wraps [method`Gio`.FileEnumerator.next_files_async].
Use [method`Dex`.Future.await_boxed] to await for the result of this function.
When on a fiber, you can do:
``c g_autolist(GFileInfo) infos = dex_await_boxed (dex_file_enumerator_next_files (enumerator, 100, 0), &error); ``
- Dex.file_load_contents_bytes(file)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes].
- Return type:
- Dex.file_make_directory(file, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future]
- Return type:
Asynchronously creates a directory and returns [class`Dex`.Future] which can be observed for the result.
- Dex.file_make_directory_with_parents(file)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]- Returns:
a [class`Dex`.Future] that resolves to a boolean or rejects with error.
- Return type:
Creates a directory at file.
If file already exists and is a directory, then the future will resolve to
True.New in version 1.0.
- Dex.file_move(source, destination, flags, io_priority, progress_callback, *progress_callback_data)¶
- Parameters:
source (
Gio.File) – source [iface`Gio`.File]destination (
Gio.File) – destination [iface`Gio`.File]flags (
Gio.FileCopyFlags) – a set of [flags`Gio`.FileCopyFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the requestprogress_callback (
Gio.FileProgressCallback) – [callback`Gio`.FileProgressCallback] function for updatesprogress_callback_data (
objectorNone) –gpointerto user data for the callback function
- Returns:
a [class`Dex`.Future] that resolves to
Trueor rejects with error- Return type:
- Dex.file_query_exists(file)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]- Returns:
a [class`Dex`.Future] that will resolve with
Trueif the file exists, otherwise reject with error.- Return type:
Queries to see if file exists asynchronously.
New in version 0.6.
- Dex.file_query_file_type(file, flags, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]flags (
Gio.FileQueryInfoFlags) – a set of [flags`Gio`.FileQueryInfoFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [enum`Gio`.FileType].
- Return type:
- Dex.file_query_info(file, attributes, flags, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]attributes (
str) – an attribute query string (see: GFile documentation)flags (
Gio.FileQueryInfoFlags) – a set of [flags`Gio`.FileQueryInfoFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileInfo] or rejects with error.
- Return type:
- Dex.file_read(file, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileInputStream].
- Return type:
Asynchronously opens a file for reading.
- Dex.file_replace(file, etag, make_backup, flags, io_priority)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileInputStream].
- Return type:
Opens a stream that will replace file on disk when the input stream is closed.
- Dex.file_replace_contents_bytes(file, contents, etag, make_backup, flags)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]contents (
GLib.Bytes) – a [struct`GLib`.Bytes]make_backup (
bool) – if a backup file should be createdflags (
Gio.FileCreateFlags) – a set of [flags`Gio`.FileCreateFlags]
- Returns:
a [class`Dex`.Future] which resolves to the new etag. Therefore, it is possible to be
Nonewithout an error having occurred.- Return type:
Wraps [method`Gio`.File.replace_contents_bytes_async]
- Dex.file_set_attributes(file, file_info, flags, io_priority)¶
- Parameters:
file (
Gio.File) – a [iface`Gio`.File]file_info (
Gio.FileInfo) – a [class`Gio`.FileInfo]flags (
Gio.FileQueryInfoFlags) – a set of [flags`Gio`.FileQueryInfoFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.FileInfo] or rejects with error.
- Return type:
New in version 1.0.
- Dex.find_program_in_path(program)¶
- Parameters:
program (
str) – the name of the executable such as “grep”- Returns:
a [class`Dex`.Future] that resolves to a string containing the path or rejects with error.
- Return type:
Locates the first executable named program in the user’s path.
This runs [func`GLib`.find_program_in_path] on a dedicated thread.
New in version 1.1.
- Dex.get_major_version()¶
- Return type:
Gets the major version number equivalent to
DEX_MAJOR_VERSIONat compile time of libdex.New in version 1.1.
- Dex.get_micro_version()¶
- Return type:
Gets the micro version number equivalent to
DEX_MICRO_VERSIONat compile time of libdex.New in version 1.1.
- Dex.get_minor_version()¶
- Return type:
Gets the minor version number equivalent to
DEX_MINOR_VERSIONat compile time of libdex.New in version 1.1.
- Dex.init()¶
- Dex.input_stream_close(self, io_priority)¶
- Parameters:
self (
Gio.InputStream) – a [class`Gio`.InputStream]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to true if successful or rejects with error.
- Return type:
- Dex.input_stream_read(self, io_priority)¶
- Parameters:
self (
Gio.InputStream) – a [class`Gio`.InputStream]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that reads counts bytes into buffer
- Return type:
(
Dex.Future, buffer:bytes)
Reads count bytes from an input stream into a pre-allocated buffer. The buffer must stay valid for the lifetime of this future.
- Dex.input_stream_read_bytes(stream, count, io_priority)¶
- Parameters:
stream (
Gio.InputStream) – a [class`Gio`.InputStream]count (
int) – size in bytes to read from the streamio_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes].
- Return type:
Reads count bytes from the stream.
- Dex.input_stream_skip(self, count, io_priority)¶
- Parameters:
self (
Gio.InputStream) – a [class`Gio`.InputStream]count (
int) – the number of bytes to skipio_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to the number of bytes skipped as a
gint64.- Return type:
- Dex.io_stream_close(io_stream, io_priority)¶
- Parameters:
io_stream (
Gio.IOStream) – a [class`Gio`.IOStream]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to true or rejects with error.
- Return type:
- Dex.mkdir_with_parents(path, mode)¶
- Parameters:
- Returns:
a [class`Dex`.Future] that resolves to 0 if successful, otherwise rejects with error.
- Return type:
Similar to [func`GLib`.mkdir_with_parents] but runs on a dedicated thread.
New in version 1.1.
- Dex.output_stream_close(self, io_priority)¶
- Parameters:
self (
Gio.OutputStream) – a [class`Gio`.OutputStream]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to true or rejects with error.
- Return type:
- Dex.output_stream_splice(output, input, flags, io_priority)¶
- Parameters:
output (
Gio.OutputStream) – a [class`Gio`.OutputStream]input (
Gio.InputStream) – a [class`Gio`.InputStream]flags (
Gio.OutputStreamSpliceFlags) – a set of [flags`Gio`.OutputStreamSpliceFlags]io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to the number of bytes spliced as a
gint64or rejects with error.- Return type:
- Dex.output_stream_write(self, buffer, io_priority)¶
- Parameters:
self (
Gio.OutputStream) – a [class`Gio`.OutputStream]buffer (
bytes) –io_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to the number of bytes written as a
gint64- Return type:
- Dex.output_stream_write_bytes(stream, bytes, io_priority)¶
- Parameters:
stream (
Gio.OutputStream) – a [class`Gio`.InputStream]bytes (
GLib.Bytes) – the [struct`GLib`.Bytes] to write to the streamio_priority (
int) – the ‘IO priority [iface@Gio.AsyncResult#io-priority]’ of the request
- Returns:
a [class`Dex`.Future] that resolves to a
gint64.- Return type:
Writes bytes to stream.
This function takes a reference to bytes and may be released after calling this function.
- Dex.resolver_lookup_by_name(resolver, address)¶
- Parameters:
resolver (
Gio.Resolver) – a [class`Gio`.Resolver]address (
str) – the address to look up
- Returns:
a [class`Dex`.Future] that resolves to a [struct`GLib`.List] of [class`Gio`.InetAddress].
- Return type:
- Dex.socket_client_connect(socket_client, socket_connectable)¶
- Parameters:
socket_client (
Gio.SocketClient) – a [class`Gio`.SocketClient]socket_connectable (
Gio.SocketConnectable) – a [iface`Gio`.SocketConnectable]
- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.SocketConnection] or rejects with error.
- Return type:
- Dex.socket_listener_accept(listener)¶
- Parameters:
listener (
Gio.SocketListener) – a [class`Gio`.SocketListener]- Returns:
a [class`Dex`.Future] that resolves to a [class`Gio`.SocketConnection] or rejects with error.
- Return type:
- Dex.subprocess_wait_check(subprocess)¶
- Parameters:
subprocess (
Gio.Subprocess) – a [class`Gio`.Subprocess]- Returns:
a [class`Dex`.Future] that will resolve when subprocess exits cleanly or reject upon signal or non-successful exit.
- Return type:
Creates a future that awaits for subprocess to complete using [method`Gio`.Subprocess.wait_check_async].
New in version 0.4.
- Dex.thread_spawn(thread_name, thread_func, *user_data)¶
- Parameters:
thread_func (
Dex.ThreadFunc) – the function to call on a thread
- Returns:
a [class`Dex`.Future] that resolves or rejects the value or error returned from thread_func as a [class`Dex`.Future].
- Return type:
Spawns a new thread named thread_name running thread_func with user_data passed to it.
thread_func must return a [class`Dex`.Future].
If this function is called from a thread that is not running a [class`Dex`.Scheduler] then the default scheduler will be used to call user_data_destroy.
If the resulting [class`Dex`.Future] has not resolved or rejected, then the same scheduler used to call user_data_destroy will be used to propagate the result to the caller.
New in version 1.0.
- Dex.thread_wait_for(future)¶
- Parameters:
future (
Dex.Future) – a [class`Dex`.Future]- Raises:
- Returns:
Trueif future resolved, otherwiseFalseand error is set to the rejection.- Return type:
Use this when running on a thread spawned with
dex_thread_spawn()and you need to block the thread until future has resolved or rejected.New in version 1.0.
- Dex.unlink(path)¶
- Parameters:
path (
str) – the path to unlink- Returns:
a [class`Dex`.Future] that resolves to an int of 0 on success or rejects with error.
- Return type:
This runs [func`GLib`.unlink] on a dedicated thread.
New in version 1.1.
- Dex.value_dup_object(value)¶
- Parameters:
value (
GObject.Value) – aGValueinitialized with typeDEX_TYPE_OBJECT- Returns:
a
DexObject- Return type:
Dex.ObjectorNone
Retrieves the
DexObjectstored inside the givenvalue.New in version 1.0.
- Dex.value_get_object(value)¶
- Parameters:
value (
GObject.Value) – aGValueinitialized with typeDEX_TYPE_OBJECT- Returns:
a
DexObject- Return type:
Dex.ObjectorNone
Retrieves the
DexObjectstored inside the givenvalue.New in version 0.4.
- Dex.value_set_object(value, object)¶
- Parameters:
value (
GObject.Value) – a [struct`GObject`.Value] initialized with typeDEX_TYPE_OBJECTobject (
Dex.ObjectorNone) – aDexObjectorNone
Stores the given
DexObjectinsidevalue.The [struct`GObject`.Value] will acquire a reference to the
object.New in version 0.4.
- Dex.value_take_object(value, object)¶
- Parameters:
value (
GObject.Value) – a [struct`GObject`.Value] initialized with typeDEX_TYPE_OBJECTobject (
Dex.ObjectorNone) – aDexObject
Stores the given
DexObjectinsidevalue.This function transfers the ownership of the
objectto theGValue.New in version 0.4.