[librsvg: 7/45] session.rs: new file with a Session type, to track metadata during loading/rendering




commit dc6b58d55ef74b6e0537b309052c2bba21f87ccd
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Aug 19 14:38:35 2022 -0500

    session.rs: new file with a Session type, to track metadata during loading/rendering
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 Makefile.am    |  1 +
 src/lib.rs     |  1 +
 src/session.rs | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+)
---
diff --git a/Makefile.am b/Makefile.am
index 58c2a5c9f..b962614c9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -98,6 +98,7 @@ LIBRSVG_SRC =                                 \
        src/property_defs.rs                    \
        src/property_macros.rs                  \
        src/rect.rs                             \
+       src/session.rs                          \
        src/shapes.rs                           \
        src/space.rs                            \
        src/structure.rs                        \
diff --git a/src/lib.rs b/src/lib.rs
index 3dfb39f46..ce602d444 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -209,6 +209,7 @@ mod pattern;
 mod properties;
 mod property_defs;
 mod rect;
+mod session;
 mod shapes;
 mod space;
 mod structure;
diff --git a/src/session.rs b/src/session.rs
new file mode 100644
index 000000000..8988f2fd2
--- /dev/null
+++ b/src/session.rs
@@ -0,0 +1,20 @@
+//! Tracks metadata for a loading/rendering session.
+
+use crate::log;
+
+/// Metadata for a loading/rendering session.
+///
+/// When the calling program first uses one of the API entry points (e.g. `Loader::new()`
+/// in the Rust API, or `rsvg_handle_new()` in the C API), there is no context yet where
+/// librsvg's code may start to track things.  This struct provides that context.
+pub struct Session {
+    log_enabled: bool,
+}
+
+impl Session {
+    pub fn new() -> Self {
+        Self {
+            log_enabled: log::log_enabled(),
+        }
+    }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]