Crate glib[−][src]
glib, gobject and gio bindings for Rust
This library contains
-
bindings to some essential GLib, GObject, GIO types and APIs,
-
common building blocks used in both handmade and machine generated bindings to GTK+ and other GLib-based libraries.
It is the foundation for higher level libraries with uniform Rusty (safe and strongly typed) APIs. It avoids exposing GLib-specific data types where possible and is not meant to provide comprehensive GLib bindings, which would often amount to duplicating the Rust Standard Library or other utility crates.
The library is a work in progress: expect missing functionality and breaking changes.
Dynamic typing
Most types in the GLib family have type identifiers
(Type
). Their corresponding Rust types implement
the StaticType
trait.
Dynamically typed Value
can carry values of any T: StaticType
.
Variant
can carry values of T: StaticVariantType
.
Errors
Errors are represented by Error
, which can
carry values from various error
domains (such as
FileError
).
Objects
Each class and interface has a corresponding smart pointer struct
representing an instance of that type (e.g. Object
for GObject
,
gtk::Widget
for GtkWidget
). They are reference counted and feature
interior mutability similarly to Rust's Rc<RefCell<T>>
idiom.
Consequently, cloning objects is cheap and their methods never require
mutable borrows. Two smart pointers are equal iff they point to the same
object.
The root of the object hierarchy is Object
.
Inheritance and subtyping is denoted with the IsA
marker trait. The Cast
trait enables upcasting
and downcasting.
Interfaces and non-leaf classes also have corresponding traits (e.g.
ObjectExt
and gtk::WidgetExt
), which are blanketly implemented for all
their subtypes.
Under the hood
GLib-based libraries largely operate on pointers to various boxed or
reference counted structures so the bindings have to implement corresponding
smart pointers (wrappers), which encapsulate resource management and safety
checks. Such wrappers are defined via the
glib_wrapper!
macro, which uses abstractions
defined in the wrapper
, boxed
,
shared
and object
modules.
The translate
module defines and partly implements
conversions between high level Rust types (including the aforementioned
wrappers) and their FFI counterparts.
Re-exports
pub extern crate futures; |
pub use closure::Closure; |
pub use error::Error; |
pub use error::BoolError; |
pub use object::Cast; |
pub use object::IsA; |
pub use object::Object; |
pub use object::ObjectExt; |
pub use object::WeakRef; |
pub use object::SendWeakRef; |
pub use signal::SignalHandlerId; |
pub use signal::signal_handler_block; |
pub use signal::signal_handler_disconnect; |
pub use signal::signal_handler_unblock; |
pub use signal::signal_stop_emission_by_name; |
pub use types::StaticType; |
pub use types::Type; |
pub use value::ToValue; |
pub use value::ToSendValue; |
pub use value::TypedValue; |
pub use value::SendValue; |
pub use value::Value; |
pub use value::AnyValue; |
pub use value::AnySendValue; |
pub use variant::StaticVariantType; |
pub use variant::ToVariant; |
pub use variant::Variant; |
pub use char::*; |
pub use source::*; |
pub use send_unique::SendUniqueCell; |
pub use send_unique::SendUnique; |
Modules
auto | |
boxed |
|
char | |
closure | |
error |
|
functions | |
object |
|
prelude |
Traits and essential types intended for blanket imports. |
send_unique | |
shared |
|
signal |
|
source | |
translate |
Translation between GLib/GLib-based FFI types and their Rust counterparts. |
types |
Runtime type information. |
value |
|
variant |
|
wrapper |
|
Macros
glib_boxed_wrapper |
Wrapper implementations for Boxed types. See |
glib_object_wrapper |
Wrapper implementations for Object types. See |
glib_shared_wrapper |
Wrapper implementations for shared types. See |
glib_wrapper |
Defines a wrapper type and implements the appropriate traits. |
Structs
Enums
ChecksumType | |
DateMonth | |
DateWeekday | |
FileError | |
KeyFileError | |
SeekType | |
TimeType | |
UserDirectory |
Functions
Type Definitions
DateDay | |
DateYear | |
Time | |
TimeSpan |