Functions

aio_read (aio_context, fd, offset)

aio_write (aio_context, fd, buffer, offset)

async_initable_init (initable, io_priority)

bus_get (bus_type)

bus_own_name_on_connection (connection, name, flags)

data_input_stream_read_line (stream, io_priority)

dbus_connection_call (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec)

dbus_connection_call_with_unix_fd_list (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, fd_list)

dbus_connection_close (connection)

dbus_connection_send_message_with_reply (connection, message, flags, timeout_msec)

error_quark ()

fd_watch (fd, events)

file_copy (source, destination, flags, io_priority)

file_create (file, flags, io_priority)

file_delete (file, io_priority)

file_enumerate_children (file, attributes, flags, io_priority)

file_enumerator_next_files (file_enumerator, num_files, io_priority)

file_load_contents_bytes (file)

file_make_directory (file, io_priority)

file_make_directory_with_parents (file)

file_move (source, destination, flags, io_priority, progress_callback, *progress_callback_data)

file_query_exists (file)

file_query_file_type (file, flags, io_priority)

file_query_info (file, attributes, flags, io_priority)

file_read (file, io_priority)

file_replace (file, etag, make_backup, flags, io_priority)

file_replace_contents_bytes (file, contents, etag, make_backup, flags)

file_set_attributes (file, file_info, flags, io_priority)

find_program_in_path (program)

get_major_version ()

get_micro_version ()

get_min_stack_size ()

get_minor_version ()

get_page_size ()

init ()

input_stream_close (self, io_priority)

input_stream_read (self, io_priority)

input_stream_read_bytes (stream, count, io_priority)

input_stream_skip (self, count, io_priority)

io_stream_close (io_stream, io_priority)

mkdir_with_parents (path, mode)

output_stream_close (self, io_priority)

output_stream_splice (output, input, flags, io_priority)

output_stream_write (self, buffer, io_priority)

output_stream_write_bytes (stream, bytes, io_priority)

resolver_lookup_by_name (resolver, address)

socket_client_connect (socket_client, socket_connectable)

socket_listener_accept (listener)

subprocess_wait_check (subprocess)

thread_spawn (thread_name, thread_func, *user_data)

thread_wait_for (future)

unlink (path)

value_dup_object (value)

value_get_object (value)

value_set_object (value, object)

value_take_object (value, object)

Details

Dex.aio_read(aio_context, fd, offset)
Parameters:
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 NULL for the aio_context as that will get the default aio context for your scheduler.

Dex.aio_write(aio_context, fd, buffer, offset)
Parameters:
Returns:

a future that will resolve when the write completes or rejects with error.

Return type:

Dex.Future

An asynchronous pwrite() wrapper.

Generally you want to provide NULL for the aio_context as that will get the default aio context for your scheduler.

Dex.async_initable_init(initable, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to the initable instance or rejects with error.

Return type:

Dex.Future

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:

Dex.Future

Wrapper for [func`Gio`.bus_get].

New in version 0.4.

Dex.bus_own_name_on_connection(connection, name, flags)
Parameters:
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:
Returns:

a [class`Dex`.Future] that resolves to a string containing the line (without the line terminator), or None if the end of the stream is reached.

Return type:

Dex.Future

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 (str or None) – a unique or well-known bus name or None if connection is not a message bus connection

  • object_path (str) – path of remote object

  • interface_name (str) – D-Bus interface to invoke method on

  • method_name (str) – the name of the method to invoke

  • parameters (GLib.Variant or None) – a [struct`GLib`.Variant] tuple with parameters for the method or None if not passing parameters

  • reply_type (GLib.VariantType or None) – the expected type of the reply (which will be a tuple), or None

  • flags (Gio.DBusCallFlags) – flags from the [flags`Gio`.DBusCallFlags] enumeration

  • timeout_msec (int) – the timeout in milliseconds, -1 to use the default timeout or GObject.G_MAXINT for no timeout

Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.Variant] or rejects with error.

Return type:

Dex.Future

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 (str or None) – a unique or well-known bus name or None if connection is not a message bus connection

  • object_path (str) – path of remote object

  • interface_name (str) – D-Bus interface to invoke method on

  • method_name (str) – the name of the method to invoke

  • parameters (GLib.Variant or None) – a [struct`GLib`.Variant] tuple with parameters for the method or None if not passing parameters

  • reply_type (GLib.VariantType or None) – the expected type of the reply (which will be a tuple), or None

  • flags (Gio.DBusCallFlags) – flags from the [flags`Gio`.DBusCallFlags] enumeration

  • timeout_msec (int) – the timeout in milliseconds, -1 to use the default timeout or GObject.G_MAXINT for no timeout

  • fd_list (Gio.UnixFDList or None) – 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:

Dex.Future

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 true or rejects with error.

Return type:

Dex.Future

Asynchronously closes a connection.

New in version 1.0.

Dex.dbus_connection_send_message_with_reply(connection, message, flags, timeout_msec)
Parameters:
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.error_quark()
Return type:

int

Dex.fd_watch(fd, events)
Parameters:
  • fd (int) – a file-descriptor

  • events (int) – the POLLOUT|POLLIN style bitmask to watch for

Returns:

a [class`Dex`.Future] that resolves to the revents value when events is satisfied.

Return type:

Dex.Future

Creates a new GLib.Source that 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:
Returns:

a [class`Dex`.Future] that resolves to true if successful otherwise rejects with error.

Return type:

Dex.Future

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 file

  • io_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:

Dex.Future

Wraps [method`Gio`.File.create] as a [class`Dex`.Future].

New in version 1.1.

Dex.file_delete(file, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to true or rejects with error.

Return type:

Dex.Future

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:
Returns:

a [class`Dex`.Future] that resolves to a [class`Gio`.FileEnumerator] or rejects with error.

Return type:

Dex.Future

Dex.file_enumerator_next_files(file_enumerator, num_files, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.List] of [class`Gio`.FileInfo]

Return type:

Dex.Future

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.Future

Dex.file_make_directory(file, io_priority)
Parameters:
Returns:

a [class`Dex`.Future]

Return type:

Dex.Future

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:

Dex.Future

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:
Returns:

a [class`Dex`.Future] that resolves to True or rejects with error

Return type:

Dex.Future

Dex.file_query_exists(file)
Parameters:

file (Gio.File) – a [iface`Gio`.File]

Returns:

a [class`Dex`.Future] that will resolve with True if the file exists, otherwise reject with error.

Return type:

Dex.Future

Queries to see if file exists asynchronously.

New in version 0.6.

Dex.file_query_file_type(file, flags, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [enum`Gio`.FileType].

Return type:

Dex.Future

Dex.file_query_info(file, attributes, flags, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [class`Gio`.FileInfo] or rejects with error.

Return type:

Dex.Future

Dex.file_read(file, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [class`Gio`.FileInputStream].

Return type:

Dex.Future

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:

Dex.Future

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:
Returns:

a [class`Dex`.Future] which resolves to the new etag. Therefore, it is possible to be None without an error having occurred.

Return type:

Dex.Future

Wraps [method`Gio`.File.replace_contents_bytes_async]

Dex.file_set_attributes(file, file_info, flags, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [class`Gio`.FileInfo] or rejects with error.

Return type:

Dex.Future

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:

Dex.Future

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:

int

Gets the major version number equivalent to DEX_MAJOR_VERSION at compile time of libdex.

New in version 1.1.

Dex.get_micro_version()
Return type:

int

Gets the micro version number equivalent to DEX_MICRO_VERSION at compile time of libdex.

New in version 1.1.

Dex.get_min_stack_size()
Return type:

int

Dex.get_minor_version()
Return type:

int

Gets the minor version number equivalent to DEX_MINOR_VERSION at compile time of libdex.

New in version 1.1.

Dex.get_page_size()
Return type:

int

Dex.init()
Dex.input_stream_close(self, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to true if successful or rejects with error.

Return type:

Dex.Future

Dex.input_stream_read(self, io_priority)
Parameters:
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:
Returns:

a [class`Dex`.Future] that resolves to a [struct`GLib`.Bytes].

Return type:

Dex.Future

Reads count bytes from the stream.

Dex.input_stream_skip(self, count, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to the number of bytes skipped as a gint64.

Return type:

Dex.Future

Dex.io_stream_close(io_stream, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to true or rejects with error.

Return type:

Dex.Future

Dex.mkdir_with_parents(path, mode)
Parameters:
  • path (str) – a path to a directory to create

  • mode (int) – the mode for the directory such as 0750

Returns:

a [class`Dex`.Future] that resolves to 0 if successful, otherwise rejects with error.

Return type:

Dex.Future

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:
Returns:

a [class`Dex`.Future] that resolves to true or rejects with error.

Return type:

Dex.Future

Dex.output_stream_splice(output, input, flags, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to the number of bytes spliced as a gint64 or rejects with error.

Return type:

Dex.Future

Dex.output_stream_write(self, buffer, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to the number of bytes written as a gint64

Return type:

Dex.Future

Dex.output_stream_write_bytes(stream, bytes, io_priority)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a gint64.

Return type:

Dex.Future

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.Future

Dex.socket_client_connect(socket_client, socket_connectable)
Parameters:
Returns:

a [class`Dex`.Future] that resolves to a [class`Gio`.SocketConnection] or rejects with error.

Return type:

Dex.Future

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.Future

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:

Dex.Future

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_name (str or None) – the name for the thread

  • thread_func (Dex.ThreadFunc) – the function to call on a thread

  • user_data (object or None) – closure data for thread_func

Returns:

a [class`Dex`.Future] that resolves or rejects the value or error returned from thread_func as a [class`Dex`.Future].

Return type:

Dex.Future

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:

GLib.Error

Returns:

True if future resolved, otherwise False and error is set to the rejection.

Return type:

bool

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.

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:

Dex.Future

This runs [func`GLib`.unlink] on a dedicated thread.

New in version 1.1.

Dex.value_dup_object(value)
Parameters:

value (GObject.Value) – a GValue initialized with type DEX_TYPE_OBJECT

Returns:

a DexObject

Return type:

Dex.Object or None

Retrieves the DexObject stored inside the given value.

New in version 1.0.

Dex.value_get_object(value)
Parameters:

value (GObject.Value) – a GValue initialized with type DEX_TYPE_OBJECT

Returns:

a DexObject

Return type:

Dex.Object or None

Retrieves the DexObject stored inside the given value.

New in version 0.4.

Dex.value_set_object(value, object)
Parameters:

Stores the given DexObject inside value.

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 type DEX_TYPE_OBJECT

  • object (Dex.Object or None) – a DexObject

Stores the given DexObject inside value.

This function transfers the ownership of the object to the GValue.

New in version 0.4.