begin multi-protocol page driver implementation

This commit is contained in:
yggverse 2025-01-16 12:59:53 +02:00
parent 5e2f9d6de0
commit 9d45688314
16 changed files with 796 additions and 830 deletions

View file

@ -1,5 +1,8 @@
//! Some shared helpers collection
// Global dependencies
use gtk::glib::{DateTime, GString, Uri};
/// Format bytes to KB/MB/GB presentation
pub fn format_bytes(value: usize) -> String {
const KB: f32 = 1024.0;
@ -21,3 +24,24 @@ pub fn format_bytes(value: usize) -> String {
format!("{:.2} GB", f / GB)
}
}
/// Format given [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
pub fn format_time(t: &DateTime) -> GString {
t.format_iso8601().unwrap() // @TODO handle?
}
/// Get current [DateTime](https://docs.gtk.org/glib/struct.DateTime.html)
pub fn now() -> DateTime {
DateTime::now_local().unwrap() // @TODO handle?
}
/// Compare `subject` with `base`
pub fn _is_external(subject: &Uri, base: &Uri) -> bool {
if subject.scheme() != base.scheme() {
return true;
}
if subject.port() != base.port() {
return true;
}
subject.host() != base.host()
} // @TODO not in use