From 9dbdf74a1e3c502648ab9bf8b33c7ed06a9a76b4 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 2 Aug 2024 00:38:01 +0200 Subject: [PATCH] Move the manganis into attribute value implementation into dioxus core (#2765) --- Cargo.lock | 1 + packages/core/Cargo.toml | 2 ++ packages/core/src/nodes.rs | 7 +++++++ packages/dioxus/Cargo.toml | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 56b179061..934e57eef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2578,6 +2578,7 @@ dependencies = [ "futures-util", "generational-box", "longest-increasing-subsequence", + "manganis", "pretty_assertions", "rand 0.8.5", "reqwest 0.12.5", diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index dc36ed14c..324f665e1 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -25,6 +25,7 @@ generational-box = { workspace = true } rustversion = "1.0.17" const_format = { workspace = true } warnings = { workspace = true } +manganis = { workspace = true, default-features = false, optional = true } [dev-dependencies] tokio = { workspace = true, features = ["full"] } @@ -47,6 +48,7 @@ features = [ [features] serialize = ["dep:serde"] +manganis = ["dep:manganis"] [package.metadata.docs.rs] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 798e04244..0ea518558 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -1096,6 +1096,13 @@ impl IntoAttributeValue for Option { } } +#[cfg(feature = "manganis")] +impl IntoAttributeValue for manganis::ImageAsset { + fn into_value(self) -> AttributeValue { + AttributeValue::Text(self.path().to_string()) + } +} + /// A trait for anything that has a dynamic list of attributes pub trait HasAttributes { /// Push an attribute onto the list of attributes diff --git a/packages/dioxus/Cargo.toml b/packages/dioxus/Cargo.toml index 09b5a56bc..bb999fc69 100644 --- a/packages/dioxus/Cargo.toml +++ b/packages/dioxus/Cargo.toml @@ -43,7 +43,7 @@ hooks = ["dep:dioxus-hooks"] hot-reload = ["dep:dioxus-hot-reload", "dioxus-web?/hot_reload", "dioxus-fullstack?/hot-reload"] mounted = ["dioxus-web?/mounted", "dioxus-html?/mounted"] file_engine = ["dioxus-web?/file_engine"] -asset = ["dep:manganis"] +asset = ["dep:manganis", "dioxus-core/manganis"] document = ["dioxus-web?/document", "dioxus-html?/document"] launch = ["dep:dioxus-config-macro"]