pub trait ObjectInterface:
Sized
+ ObjectInterfaceType
+ 'static {
type Prerequisites: PrerequisiteList;
type Instance;
type Interface: InterfaceStruct<Type = Self>;
const NAME: &'static str;
const ALLOW_NAME_CONFLICT: bool = false;
// Provided methods
fn type_init(_type_: &mut InitializingType<Self>) { ... }
fn interface_init(_klass: &mut Self::Interface) { ... }
fn properties() -> &'static [ParamSpec] { ... }
fn signals() -> &'static [Signal] { ... }
}
Expand description
The central trait for defining a GObject
interface.
Links together the type name, the empty instance and class structs for type registration and allows hooking into various steps of the type registration and initialization.
See register_interface
for registering an implementation of this trait
with the type system.
Required Associated Constants§
Provided Associated Constants§
Sourceconst ALLOW_NAME_CONFLICT: bool = false
const ALLOW_NAME_CONFLICT: bool = false
Allow name conflicts for this class.
By default, trying to register a type with a name that was registered before will panic. If
this is set to true
then a new name will be selected by appending a counter.
This is useful for defining new types in Rust library crates that might be linked multiple times in the same process.
A consequence of setting this to true
is that it’s not guaranteed that
glib::Type::from_name(Self::NAME).unwrap() == Self::type_()
.
Note that this is not allowed for dynamic types. If a dynamic type is registered and a type with that name exists already, it is assumed that they’re the same.
Optional.
Required Associated Types§
Sourcetype Prerequisites: PrerequisiteList
type Prerequisites: PrerequisiteList
Prerequisites for this interface.
Any implementer of the interface must be a subclass of the prerequisites or implement them in case of interfaces.
Sourcetype Instance
type Instance
The C instance struct. This is usually either std::ffi::c_void
or a newtype wrapper
around it.
Optional
Sourcetype Interface: InterfaceStruct<Type = Self>
type Interface: InterfaceStruct<Type = Self>
The C class struct.
Provided Methods§
Sourcefn type_init(_type_: &mut InitializingType<Self>)
fn type_init(_type_: &mut InitializingType<Self>)
Additional type initialization.
This is called right after the type was registered and allows interfaces to do additional type-specific initialization.
Optional
Sourcefn interface_init(_klass: &mut Self::Interface)
fn interface_init(_klass: &mut Self::Interface)
Interface initialization.
This is called after type_init
and before the first implementor
of the interface is created. Interfaces can use this to do interface-
specific initialization, e.g. for installing signals on the interface,
and for setting default implementations of interface functions.
Optional
Sourcefn properties() -> &'static [ParamSpec]
fn properties() -> &'static [ParamSpec]
Properties installed for this interface.
All implementors of the interface must provide these properties.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.