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