1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![allow(clippy::missing_safety_doc)]
5#![allow(renamed_and_removed_lints)]
6#![doc = include_str!("../README.md")]
7
8pub use bitflags;
9pub use ffi;
10#[doc(hidden)]
11pub use glib_macros::cstr_bytes;
12pub use glib_macros::{
13 clone, closure, closure_local, derived_properties, flags, object_interface, object_subclass,
14 Boxed, Downgrade, Enum, ErrorDomain, Properties, SharedBoxed, ValueDelegate, Variant,
15};
16pub use gobject_ffi;
17pub use once_cell;
18
19pub use self::{
20 byte_array::ByteArray,
21 bytes::Bytes,
22 closure::{Closure, RustClosure},
23 enums::{EnumClass, EnumValue, FlagsBuilder, FlagsClass, FlagsValue, UserDirectory},
24 error::{BoolError, Error},
25 object::{
26 BorrowedObject, Cast, CastNone, Class, InitiallyUnowned, Interface, IsA, Object, ObjectExt,
27 ObjectType, SendWeakRef, WeakRef,
28 },
29 signal::{
30 signal_handler_block, signal_handler_disconnect, signal_handler_unblock,
31 signal_stop_emission_by_name, Propagation, SignalHandlerId,
32 },
33 types::{ILong, Pointer, StaticType, StaticTypeExt, Type, ULong},
34 value::{BoxedValue, SendValue, ToSendValue, ToValue, Value},
35 variant::{
36 FixedSizeVariantArray, FixedSizeVariantType, FromVariant, StaticVariantType, ToVariant,
37 Variant,
38 },
39 variant_dict::VariantDict,
40 variant_iter::{VariantIter, VariantStrIter},
41 variant_type::{VariantTy, VariantTyIterator, VariantType},
42 FileError,
43};
44
45// Hack for the time being to retrieve the current function's name as a string.
46// Based on the stdext cratelicensed under the MIT license.
47//
48// Copyright (c) 2020 Igor Aleksanov
49//
50// Previous attempts to get such a macro into std:
51// * https://github.com/rust-lang/rfcs/pull/466
52// * https://github.com/rust-lang/rfcs/pull/1719
53// * https://github.com/rust-lang/rfcs/issues/1743
54// * https://github.com/rust-lang/rfcs/pull/2818
55// * ...
56// rustdoc-stripper-ignore-next
57/// This macro returns the name of the enclosing function.
58/// As the internal implementation is based on the [`std::any::type_name`], this macro derives
59/// all the limitations of this function.
60///
61/// ## Examples
62///
63/// ```rust
64/// mod bar {
65/// pub fn sample_function() {
66/// assert!(glib::function_name!().ends_with("bar::sample_function"));
67/// }
68/// }
69///
70/// bar::sample_function();
71/// ```
72///
73/// [`std::any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
74#[macro_export]
75macro_rules! function_name {
76 () => {{
77 // Okay, this is ugly, I get it. However, this is the best we can get on a stable rust.
78 fn f() {}
79 fn type_name_of<T>(_: T) -> &'static str {
80 std::any::type_name::<T>()
81 }
82 let name = type_name_of(f);
83 // `3` is the length of the `::f`.
84 &name[..name.len() - 3]
85 }};
86}
87
88pub mod clone;
89#[macro_use]
90pub mod wrapper;
91#[macro_use]
92pub mod boxed;
93#[macro_use]
94pub mod boxed_inline;
95#[macro_use]
96pub mod shared;
97#[macro_use]
98pub mod error;
99#[macro_use]
100pub mod object;
101
102mod boxed_any_object;
103pub use boxed_any_object::BoxedAnyObject;
104mod exit_code;
105pub use exit_code::ExitCode;
106
107pub mod collections;
108pub use collections::{
109 ptr_slice::IntoPtrSlice, strv::IntoStrV, List, PtrSlice, SList, Slice, StrV,
110};
111
112pub use self::auto::{functions::*, *};
113#[allow(clippy::too_many_arguments)]
114#[allow(clippy::type_complexity)]
115#[allow(unused_imports)]
116#[allow(non_upper_case_globals)]
117mod auto;
118
119pub use self::gobject::*;
120mod gobject;
121
122mod byte_array;
123mod bytes;
124mod control_flow;
125pub use self::control_flow::ControlFlow;
126pub mod char;
127pub use self::char::*;
128mod checksum;
129pub mod closure;
130mod convert;
131pub use self::convert::*;
132mod enums;
133mod manual_functions;
134pub use self::manual_functions::*;
135mod key_file;
136pub mod prelude;
137pub mod signal;
138pub mod source;
139pub use self::source::*;
140#[macro_use]
141pub mod translate;
142mod gstring;
143pub use self::gstring::*;
144mod gstring_builder;
145pub use self::gstring_builder::GStringBuilder;
146pub mod types;
147mod unicollate;
148pub use self::unicollate::{CollationKey, FilenameCollationKey};
149mod utils;
150pub use self::utils::*;
151mod unichar;
152pub use self::unichar::*;
153mod main_context;
154mod main_context_channel;
155pub use self::{
156 main_context::MainContextAcquireGuard,
157 main_context_channel::{Receiver, Sender, SyncSender},
158};
159mod date;
160mod date_time;
161mod time_span;
162mod time_zone;
163pub use self::time_span::*;
164pub mod value;
165pub mod variant;
166mod variant_dict;
167mod variant_iter;
168mod variant_type;
169pub use self::date::Date;
170mod value_array;
171pub use self::value_array::ValueArray;
172mod param_spec;
173pub use self::param_spec::*;
174mod property;
175pub use self::property::*;
176mod quark;
177pub use self::quark::Quark;
178#[macro_use]
179mod log;
180#[doc(hidden)]
181#[cfg(feature = "log_macros")]
182#[cfg_attr(docsrs, doc(cfg(feature = "log_macros")))]
183pub use rs_log;
184
185pub use self::log::{
186 log_default_handler, log_remove_handler, log_set_always_fatal, log_set_default_handler,
187 log_set_fatal_mask, log_set_handler, log_set_writer_func, log_structured_array,
188 log_unset_default_handler, log_variant, log_writer_default, log_writer_format_fields,
189 log_writer_journald, log_writer_standard_streams, set_print_handler, set_printerr_handler,
190 unset_print_handler, unset_printerr_handler, LogField, LogHandlerId, LogLevel, LogLevels,
191};
192#[cfg(feature = "v2_68")]
193pub use self::log::{log_writer_default_set_use_stderr, log_writer_default_would_drop};
194#[cfg(unix)]
195pub use self::log::{log_writer_is_journald, log_writer_supports_color};
196
197#[cfg(feature = "log")]
198#[cfg_attr(docsrs, doc(cfg(feature = "log")))]
199#[macro_use]
200mod bridged_logging;
201#[cfg(feature = "log")]
202#[cfg_attr(docsrs, doc(cfg(feature = "log")))]
203pub use self::bridged_logging::{rust_log_handler, GlibLogger, GlibLoggerDomain, GlibLoggerFormat};
204
205#[macro_use]
206pub mod subclass;
207
208mod main_context_futures;
209pub use main_context_futures::{JoinError, JoinHandle, SpawnWithinJoinHandle};
210mod source_futures;
211pub use self::source_futures::*;
212
213mod future_with_timeout;
214pub use self::future_with_timeout::*;
215
216mod thread_pool;
217pub use self::thread_pool::{ThreadHandle, ThreadPool};
218
219pub mod thread_guard;
220
221// rustdoc-stripper-ignore-next
222/// This is the log domain used by the [`clone!`][crate::clone!] macro. If you want to use a custom
223/// logger (it prints to stdout by default), you can set your own logger using the corresponding
224/// `log` functions.
225pub const CLONE_MACRO_LOG_DOMAIN: &str = "glib-rs-clone";
226
227#[cfg(target_family = "windows")]
228mod win32;
229
230#[cfg(target_family = "windows")]
231pub use self::win32::*;
232