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 | |
8 | pub use bitflags; |
9 | pub use ffi; |
10 | #[doc (hidden)] |
11 | pub use glib_macros::cstr_bytes; |
12 | pub 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 | }; |
16 | pub use gobject_ffi; |
17 | pub use once_cell; |
18 | |
19 | pub 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 ] |
75 | macro_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 | |
88 | pub mod clone; |
89 | #[macro_use ] |
90 | pub mod wrapper; |
91 | #[macro_use ] |
92 | pub mod boxed; |
93 | #[macro_use ] |
94 | pub mod boxed_inline; |
95 | #[macro_use ] |
96 | pub mod shared; |
97 | #[macro_use ] |
98 | pub mod error; |
99 | #[macro_use ] |
100 | pub mod object; |
101 | |
102 | mod boxed_any_object; |
103 | pub use boxed_any_object::BoxedAnyObject; |
104 | mod exit_code; |
105 | pub use exit_code::ExitCode; |
106 | |
107 | pub mod collections; |
108 | pub use collections::{ |
109 | ptr_slice::IntoPtrSlice, strv::IntoStrV, List, PtrSlice, SList, Slice, StrV, |
110 | }; |
111 | |
112 | pub 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)] |
117 | mod auto; |
118 | |
119 | pub use self::gobject::*; |
120 | mod gobject; |
121 | |
122 | mod byte_array; |
123 | mod bytes; |
124 | mod control_flow; |
125 | pub use self::control_flow::ControlFlow; |
126 | pub mod char; |
127 | pub use self::char::*; |
128 | mod checksum; |
129 | pub mod closure; |
130 | mod convert; |
131 | pub use self::convert::*; |
132 | mod enums; |
133 | mod manual_functions; |
134 | pub use self::manual_functions::*; |
135 | mod key_file; |
136 | pub mod prelude; |
137 | pub mod signal; |
138 | pub mod source; |
139 | pub use self::source::*; |
140 | #[macro_use ] |
141 | pub mod translate; |
142 | mod gstring; |
143 | pub use self::gstring::*; |
144 | mod gstring_builder; |
145 | pub use self::gstring_builder::GStringBuilder; |
146 | pub mod types; |
147 | mod unicollate; |
148 | pub use self::unicollate::{CollationKey, FilenameCollationKey}; |
149 | mod utils; |
150 | pub use self::utils::*; |
151 | mod unichar; |
152 | pub use self::unichar::*; |
153 | mod main_context; |
154 | mod main_context_channel; |
155 | pub use self::{ |
156 | main_context::MainContextAcquireGuard, |
157 | main_context_channel::{Receiver, Sender, SyncSender}, |
158 | }; |
159 | mod date; |
160 | mod date_time; |
161 | mod time_span; |
162 | mod time_zone; |
163 | pub use self::time_span::*; |
164 | pub mod value; |
165 | pub mod variant; |
166 | mod variant_dict; |
167 | mod variant_iter; |
168 | mod variant_type; |
169 | pub use self::date::Date; |
170 | mod value_array; |
171 | pub use self::value_array::ValueArray; |
172 | mod param_spec; |
173 | pub use self::param_spec::*; |
174 | mod property; |
175 | pub use self::property::*; |
176 | mod quark; |
177 | pub use self::quark::Quark; |
178 | #[macro_use ] |
179 | mod log; |
180 | #[doc (hidden)] |
181 | #[cfg (feature = "log_macros" )] |
182 | #[cfg_attr (docsrs, doc(cfg(feature = "log_macros" )))] |
183 | pub use rs_log; |
184 | |
185 | pub 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" )] |
193 | pub use self::log::{log_writer_default_set_use_stderr, log_writer_default_would_drop}; |
194 | #[cfg (unix)] |
195 | pub 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 ] |
200 | mod bridged_logging; |
201 | #[cfg (feature = "log" )] |
202 | #[cfg_attr (docsrs, doc(cfg(feature = "log" )))] |
203 | pub use self::bridged_logging::{rust_log_handler, GlibLogger, GlibLoggerDomain, GlibLoggerFormat}; |
204 | |
205 | #[macro_use ] |
206 | pub mod subclass; |
207 | |
208 | mod main_context_futures; |
209 | pub use main_context_futures::{JoinError, JoinHandle, SpawnWithinJoinHandle}; |
210 | mod source_futures; |
211 | pub use self::source_futures::*; |
212 | |
213 | mod future_with_timeout; |
214 | pub use self::future_with_timeout::*; |
215 | |
216 | mod thread_pool; |
217 | pub use self::thread_pool::{ThreadHandle, ThreadPool}; |
218 | |
219 | pub 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. |
225 | pub const CLONE_MACRO_LOG_DOMAIN: &str = "glib-rs-clone" ; |
226 | |
227 | #[cfg (target_family = "windows" )] |
228 | mod win32; |
229 | |
230 | #[cfg (target_family = "windows" )] |
231 | pub use self::win32::*; |
232 | |