#![doc(
html_logo_url = "https://raw.githubusercontent.com/maps4print/azul/master/assets/images/azul_logo_full_min.svg.png",
html_favicon_url = "https://raw.githubusercontent.com/maps4print/azul/master/assets/images/favicon.ico"
)]
#![deny(unused_must_use)]
#![warn(clippy::all)]
#![warn(
clippy::pedantic,
clippy::nursery,
clippy::cargo,
// missing_docs, // TODO(docs): re-enable as a dedicated final docs pass; disabled
// // for now so the cleanup focuses on code-quality lints, not doc debt.
missing_debug_implementations,
missing_copy_implementations,
unreachable_pub,
unused_qualifications,
unused_lifetimes,
unused_import_braces,
unused_macro_rules,
unused_crate_dependencies,
meta_variable_misuse,
trivial_casts,
trivial_numeric_casts,
elided_lifetimes_in_paths,
single_use_lifetimes,
variant_size_differences,
non_ascii_idents,
unsafe_op_in_unsafe_fn,
let_underscore_drop,
)]
#![allow(
// `unknown_lints` lets the two forward-compat lints below be listed even on
// the CI toolchain (1.88), where they are not yet known, without emitting an
// "unknown lint" warning of their own. They still apply on newer rustc.
unknown_lints,
mismatched_lifetime_syntaxes, // newer rustc; fires in macro-generated code
function_casts_as_integer, // newer rustc; widget callback pointer identity
// pervasive + feature-sensitive (unused under one feature, live under another):
unused_imports,
unused_variables,
unused_mut,
dead_code,
// design lint, pervasive across the layout solver / renderer:
clippy::too_many_arguments,
// churny / 3rd-party, low value to scope:
clippy::legacy_numeric_constants,
unexpected_cfgs, // web-lift diagnostic cfgs
deprecated, // image crate tiff encoder (only under `tiff`)
// transitive dependency-version dups not resolvable in azul's source —
// syn 1↔2 (proc-macro migration), heck/jni-sys/rustc-hash/rustls-webpki;
// re-audit when the dep tree aligns.
clippy::multiple_crate_versions,
)]
#[macro_use]
extern crate alloc;
extern crate core;
#[cfg(feature = "icons")]
use brotli_decompressor as _;
use lru as _;
#[cfg(feature = "text_layout")]
use unicode_normalization as _;
#[cfg(feature = "xml")]
use xmlwriter as _;
#[cfg(feature = "web_lift")]
#[inline]
pub unsafe fn az_mark(_addr: u32, _val: u32) {
core::ptr::write_volatile(_addr as usize as *mut u32, _val);
}
#[cfg(not(feature = "web_lift"))]
#[inline]
pub const unsafe fn az_mark(_addr: u32, _val: u32) {}
#[cfg(feature = "web_lift")]
#[inline]
#[must_use] pub unsafe fn az_mark_read(_addr: u32) -> u32 {
core::ptr::read_volatile(_addr as usize as *const u32)
}
#[cfg(not(feature = "web_lift"))]
#[inline]
#[must_use] pub const unsafe fn az_mark_read(_addr: u32) -> u32 {
0
}
pub mod font_traits;
pub mod probe;
#[cfg(feature = "image_decoding")]
pub mod image;
#[cfg(feature = "text_layout")]
#[allow(private_interfaces)]
pub mod managers;
#[cfg(feature = "text_layout")]
#[allow(
dropping_references,
private_interfaces,
unreachable_patterns,
unused_parens,
unused_doc_comments,
unused_assignments
)]
pub mod solver3;
#[cfg(feature = "strfmt")]
pub mod fmt;
#[cfg(feature = "strfmt")]
pub use fmt::{FmtArg, FmtArgVec, FmtArgVecDestructor, FmtValue, fmt_string};
#[cfg(feature = "widgets")]
#[allow(unused_assignments, improper_ctypes_definitions)]
pub mod widgets;
#[cfg(feature = "extra")]
pub mod desktop;
#[cfg(any(
feature = "icu",
all(target_os = "macos", feature = "icu_macos"),
all(target_os = "windows", feature = "icu_windows"),
))]
pub mod icu;
#[cfg(any(
feature = "icu",
all(target_os = "macos", feature = "icu_macos"),
all(target_os = "windows", feature = "icu_windows"),
))]
pub use icu::{
DateTimeFieldSet, FormatLength, IcuDate, IcuDateTime, IcuError,
IcuLocalizer, IcuLocalizerHandle, IcuResult, IcuStringVec, IcuTime,
LayoutCallbackInfoIcuExt, ListType, PluralCategory,
};
#[cfg(feature = "fluent")]
pub mod fluent;
#[cfg(feature = "fluent")]
pub use fluent::{
check_fluent_syntax, check_fluent_syntax_bytes, create_fluent_zip,
create_fluent_zip_from_strings, export_to_zip, FluentError,
FluentLanguageInfo, FluentLanguageInfoVec, FluentLoadError, FluentLoadErrorVec,
FluentLocalizerHandle, FluentSyntaxCheckResult,
FluentZipLoadResult,
};
pub use azul_core::url;
pub use azul_core::url::{Url, UrlParseError, ResultUrlUrlParseError};
#[allow(unused_doc_comments, clippy::should_implement_trait)]
pub mod file;
pub use file::{
dir_create, dir_create_all, dir_list, dir_delete, dir_delete_all,
file_append, file_copy, path_exists, file_metadata, file_read, file_read_string,
file_delete, file_rename, file_write, file_write_string,
path_canonicalize, path_extension, path_file_name, path_is_dir, path_is_file,
path_join, path_parent, temp_dir,
DirEntry, DirEntryVec, DirEntryVecDestructor, DirEntryVecDestructorType,
FileError, FileErrorKind, FileMetadata, FilePath, OptionFilePath,
};
pub mod http;
pub use http::{
download_bytes, download_bytes_with_config, http_get,
http_get_with_config, is_url_reachable, HttpError, HttpHeader,
HttpRequestConfig, HttpResponse, HttpResponseTooLargeError, HttpResult,
HttpStatusError,
};
#[cfg(feature = "json")]
pub mod json;
#[cfg(feature = "json")]
pub use json::{
json_parse, json_stringify,
Json, JsonInternal, JsonKeyValue, JsonKeyValueVec, JsonKeyValueVecDestructor, JsonKeyValueVecDestructorType,
JsonParseError, JsonType, JsonVec,
ResultJsonJsonParseError, OptionJson, OptionJsonVec, OptionJsonKeyValueVec,
};
#[cfg(feature = "zip")]
pub mod zip;
#[cfg(feature = "zip")]
pub use zip::{
zip_create, zip_create_from_files, zip_extract_all, zip_list_contents,
ZipFile, ZipFileEntry, ZipFileEntryVec, ZipPathEntry, ZipPathEntryVec,
ZipReadConfig, ZipWriteConfig, ZipReadError, ZipWriteError,
};
pub mod icon;
pub use icon::{
default_icon_resolver,
ImageIconData, FontIconData,
register_image_icon,
register_font_icon,
register_icons_from_zip,
create_default_icon_provider,
register_material_icons,
register_embedded_material_icons,
};
pub use azul_core::icon::{
IconProviderHandle, IconResolverCallbackType,
resolve_icons_in_styled_dom, OptionIconProviderHandle,
};
#[cfg(feature = "text_layout")]
pub mod callbacks;
#[cfg(feature = "cpurender")]
#[allow(clippy::type_complexity)]
pub mod cpurender;
#[cfg(feature = "cpurender")]
pub mod glyph_cache;
#[cfg(feature = "text_layout")]
pub mod default_actions;
#[cfg(feature = "text_layout")]
pub mod event_determination;
#[cfg(feature = "text_layout")]
#[allow(clippy::type_complexity)]
pub mod font;
#[cfg(feature = "text_layout")]
pub mod headless;
#[cfg(feature = "text_layout")]
pub use allsorts::subset::CmapTarget;
#[cfg(feature = "text_layout")]
pub use font::parsed::{
FontParseWarning, FontParseWarningSeverity, FontType, OwnedGlyph, ParsedFont, PdfFontMetrics,
SubsetFont,
};
#[cfg(feature = "text_layout_hyphenation")]
pub use hyphenation;
#[cfg(feature = "text_layout")]
pub mod hit_test;
pub use azul_core::paged;
#[cfg(feature = "text_layout")]
#[allow(private_interfaces, unused_labels, clippy::type_complexity)]
pub mod text3;
#[cfg(feature = "text_layout")]
pub mod thread;
#[cfg(feature = "text_layout")]
#[allow(clippy::non_canonical_partial_ord_impl)]
pub mod timer;
#[cfg(feature = "text_layout")]
pub mod scroll_timer;
#[cfg(feature = "text_layout")]
#[allow(unused_parens)]
pub mod window;
#[cfg(feature = "text_layout")]
pub mod window_state;
#[cfg(feature = "xml")]
#[allow(unused_assignments)]
pub mod xml;
pub use paged::PageMargins;
#[cfg(feature = "text_layout")]
pub use hit_test::{CursorTypeHitTest, FullHitTest};
#[cfg(feature = "text_layout")]
pub use solver3::cache::LayoutCache as Solver3LayoutCache;
#[cfg(feature = "text_layout")]
pub use solver3::display_list::DisplayList as DisplayList3;
#[cfg(feature = "text_layout")]
pub use solver3::layout_document;
#[cfg(feature = "text_layout")]
pub use solver3::paged_layout::layout_document_paged;
#[cfg(feature = "text_layout")]
pub use solver3::{LayoutContext, LayoutError, Result as LayoutResult3};
#[cfg(feature = "text_layout")]
pub use text3::cache::{FontContext, FontManager, TextShapingCache};
#[cfg(feature = "text_layout")]
pub use text3::cache::TextShapingCache as TextLayoutCache;
#[cfg(feature = "font_async_registry")]
pub use rust_fontconfig::registry::FcFontRegistry;
#[cfg(feature = "text_layout")]
pub use window::{CursorBlinkTimerAction, LayoutWindow, ScrollbarDragState, TooltipTimerAction};
#[cfg(feature = "text_layout")]
pub use managers::text_input::{PendingTextEdit, OptionPendingTextEdit};
#[cfg(feature = "text_layout")]
#[allow(clippy::needless_pass_by_value)]
pub fn parse_font_fn(
source: azul_core::resources::LoadedFontSource,
) -> Option<azul_css::props::basic::FontRef> {
use crate::font::parsed::ParsedFont;
ParsedFont::from_bytes(
source.data.as_ref(),
source.index as usize,
&mut Vec::new(), )
.map(parsed_font_to_font_ref)
}
#[cfg(feature = "text_layout")]
pub fn parsed_font_to_font_ref(
parsed_font: ParsedFont,
) -> azul_css::props::basic::FontRef {
use core::ffi::c_void;
extern "C" fn parsed_font_destructor(ptr: *mut c_void) {
unsafe {
drop(Box::from_raw(ptr.cast::<ParsedFont>()));
}
}
let boxed = Box::new(parsed_font);
let raw_ptr = Box::into_raw(boxed) as *const c_void;
azul_css::props::basic::FontRef::new(raw_ptr, parsed_font_destructor)
}
#[cfg(feature = "text_layout")]
#[must_use] pub const fn font_ref_to_parsed_font(
font_ref: &azul_css::props::basic::FontRef,
) -> &ParsedFont {
unsafe { &*font_ref.parsed.cast::<ParsedFont>() }
}