1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// Take a look at the license at the top of the repository in the LICENSE file.

#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![allow(clippy::missing_safety_doc)]
#![doc = include_str!("../README.md")]

#[doc(hidden)]
pub use bitflags;
pub use ffi;
#[doc(hidden)]
pub use glib_macros::cstr_bytes;
pub use glib_macros::{
    clone, closure, closure_local, flags, object_interface, object_subclass, Boxed, Downgrade,
    Enum, ErrorDomain, Properties, SharedBoxed, ValueDelegate, Variant,
};
pub use gobject_ffi;
#[doc(hidden)]
pub use once_cell;

pub use self::{
    byte_array::ByteArray,
    bytes::Bytes,
    closure::{Closure, RustClosure},
    enums::{EnumClass, EnumValue, FlagsBuilder, FlagsClass, FlagsValue, UserDirectory},
    error::{BoolError, Error},
    object::{
        BorrowedObject, Cast, CastNone, Class, InitiallyUnowned, Interface, IsA, Object, ObjectExt,
        ObjectType, SendWeakRef, WeakRef,
    },
    signal::{
        signal_handler_block, signal_handler_disconnect, signal_handler_unblock,
        signal_stop_emission_by_name, SignalHandlerId,
    },
    types::{ILong, Pointer, StaticType, StaticTypeExt, Type, ULong},
    value::{BoxedValue, SendValue, ToSendValue, ToValue, Value},
    variant::{
        FixedSizeVariantArray, FixedSizeVariantType, FromVariant, StaticVariantType, ToVariant,
        Variant,
    },
    variant_dict::VariantDict,
    variant_iter::{VariantIter, VariantStrIter},
    variant_type::{VariantTy, VariantTyIterator, VariantType},
    FileError,
};

// Hack for the time being to retrieve the current function's name as a string.
// Based on the stdext cratelicensed under the MIT license.
//
// Copyright (c) 2020 Igor Aleksanov
//
// Previous attempts to get such a macro into std:
// * https://github.com/rust-lang/rfcs/pull/466
// * https://github.com/rust-lang/rfcs/pull/1719
// * https://github.com/rust-lang/rfcs/issues/1743
// * https://github.com/rust-lang/rfcs/pull/2818
// * ...
// rustdoc-stripper-ignore-next
/// This macro returns the name of the enclosing function.
/// As the internal implementation is based on the [`std::any::type_name`], this macro derives
/// all the limitations of this function.
///
/// ## Examples
///
/// ```rust
/// mod bar {
///     pub fn sample_function() {
///         assert!(glib::function_name!().ends_with("bar::sample_function"));
///     }
/// }
///
/// bar::sample_function();
/// ```
///
/// [`std::any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
#[macro_export]
macro_rules! function_name {
    () => {{
        // Okay, this is ugly, I get it. However, this is the best we can get on a stable rust.
        fn f() {}
        fn type_name_of<T>(_: T) -> &'static str {
            std::any::type_name::<T>()
        }
        let name = type_name_of(f);
        // `3` is the length of the `::f`.
        &name[..name.len() - 3]
    }};
}

pub mod clone;
#[macro_use]
pub mod wrapper;
#[macro_use]
pub mod boxed;
#[macro_use]
pub mod boxed_inline;
#[macro_use]
pub mod shared;
#[macro_use]
pub mod error;
#[macro_use]
pub mod object;

mod boxed_any_object;
pub use boxed_any_object::BoxedAnyObject;
mod exit_code;
pub use exit_code::ExitCode;

pub mod collections;
pub use collections::{
    ptr_slice::IntoPtrSlice, strv::IntoStrV, List, PtrSlice, SList, Slice, StrV,
};

pub use self::auto::{functions::*, *};
#[allow(clippy::too_many_arguments)]
#[allow(clippy::type_complexity)]
#[allow(unused_imports)]
#[allow(non_upper_case_globals)]
mod auto;

pub use self::gobject::*;
mod gobject;

mod byte_array;
mod bytes;
pub mod char;
pub use self::char::*;
mod checksum;
pub mod closure;
mod convert;
pub use self::convert::*;
mod enums;
mod functions;
pub use self::functions::*;
mod key_file;
pub mod prelude;
pub mod signal;
pub mod source;
pub use self::source::*;
#[macro_use]
pub mod translate;
mod gstring;
pub use self::gstring::*;
mod gstring_builder;
pub use self::gstring_builder::GStringBuilder;
pub mod types;
mod unicollate;
pub use self::unicollate::{CollationKey, FilenameCollationKey};
mod utils;
pub use self::utils::*;
mod main_context;
mod main_context_channel;
pub use self::{
    main_context::MainContextAcquireGuard,
    main_context_channel::{Receiver, Sender, SyncSender},
};
mod date;
mod date_time;
mod time_span;
mod time_zone;
pub use self::time_span::*;
pub mod value;
pub mod variant;
mod variant_dict;
mod variant_iter;
mod variant_type;
pub use self::date::Date;
mod value_array;
pub use self::value_array::ValueArray;
mod param_spec;
pub use self::param_spec::*;
mod property;
pub use self::property::*;
mod quark;
pub use self::quark::Quark;
#[macro_use]
mod log;
#[doc(hidden)]
#[cfg(any(feature = "dox", feature = "log_macros"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "log_macros")))]
pub use rs_log;

pub use self::log::{
    log_default_handler, log_remove_handler, log_set_always_fatal, log_set_default_handler,
    log_set_fatal_mask, log_set_handler, log_set_writer_func, log_structured_array,
    log_unset_default_handler, log_variant, log_writer_default, log_writer_format_fields,
    log_writer_journald, log_writer_standard_streams, set_print_handler, set_printerr_handler,
    unset_print_handler, unset_printerr_handler, LogField, LogHandlerId, LogLevel, LogLevels,
};
#[cfg(any(feature = "v2_68", feature = "dox"))]
pub use self::log::{log_writer_default_set_use_stderr, log_writer_default_would_drop};
#[cfg(any(unix, feature = "dox"))]
pub use self::log::{log_writer_is_journald, log_writer_supports_color};

#[cfg(any(feature = "log", feature = "dox"))]
#[macro_use]
mod bridged_logging;
#[cfg(any(feature = "log", feature = "dox"))]
pub use self::bridged_logging::{rust_log_handler, GlibLogger, GlibLoggerDomain, GlibLoggerFormat};

#[macro_use]
pub mod subclass;

mod main_context_futures;
pub use main_context_futures::{JoinError, JoinHandle, SpawnWithinJoinHandle};
mod source_futures;
pub use self::source_futures::*;

mod future_with_timeout;
pub use self::future_with_timeout::*;

mod thread_pool;
pub use self::thread_pool::{ThreadHandle, ThreadPool};

pub mod thread_guard;

// rustdoc-stripper-ignore-next
/// This is the log domain used by the [`clone!`][crate::clone!] macro. If you want to use a custom
/// logger (it prints to stdout by default), you can set your own logger using the corresponding
/// `log` functions.
pub const CLONE_MACRO_LOG_DOMAIN: &str = "glib-rs-clone";

#[cfg(target_family = "windows")]
mod win32;

#[cfg(target_family = "windows")]
pub use self::win32::*;