Merge branch 'master' into pr/atty303/1349

This commit is contained in:
Evan Almloff committed 2023-09-20 16:19:23 -05:00
commit 7033276c34
444 files changed
+2868 -14315

No files matched your search

+2
View File
@@ -1265,6 +1265,8 @@ builder_constructors! {
spellcheck: BoolOrDefault DEFAULT,
wrap: Wrap DEFAULT,
value: String volatile,
initial_value: String DEFAULT,
};
+10 -1
View File
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Debug};
use std::{any::Any, collections::HashMap, fmt::Debug};
use dioxus_core::Event;
@@ -45,6 +45,12 @@ impl FileEngine for SerializedFileEngine {
.await
.map(|bytes| String::from_utf8_lossy(&bytes).to_string())
}
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>> {
self.read_file(file)
.await
.map(|val| Box::new(val) as Box<dyn Any>)
}
}
#[cfg(feature = "serialize")]
@@ -89,6 +95,9 @@ pub trait FileEngine {
// read a file to string
async fn read_file_to_string(&self, file: &str) -> Option<String>;
// returns a file in platform's native representation
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>>;
}
impl_event! {
+1 -1
View File
@@ -108,7 +108,7 @@ impl_event! {
///
/// ## Example
/// ```rust, ignore
/// rsx!( button { "click me", onclick: move |_| log::info!("Clicked!`") } )
/// rsx!( button { "click me", onclick: move |_| tracing::info!("Clicked!`") } )
/// ```
///
/// ## Reference
@@ -1,3 +1,4 @@
use std::any::Any;
use std::path::PathBuf;
use crate::FileEngine;
@@ -40,4 +41,9 @@ impl FileEngine for NativeFileEngine {
Some(contents)
}
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>> {
let file = File::open(file).await.ok()?;
Some(Box::new(file))
}
}