text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>pub(crate) mod autoformat;
pub(crate) mod build;
pub(crate) mod build_assets;
pub(crate) mod bundle;
pub(crate) mod check;
pub(crate) mod component;
pub(crate) mod config;
pub(crate) mod create;
pub(crate) mod doctor;
pub(crate) mod hotpatch;
pub(crate) mod init;
pub(crate) mod link;
pub(crate) mod platfo... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>undle",
"--platform",
"desktop",
"@client",
"--release",
"@server",
"--platform",
"server",
])
.expect("platform override subcommands should parse");
let crate::Commands::Bundle(bundle) = cli.actio... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> PrintStyle::Unix
} else {
PrintStyle::Cmd
}
});
match style {
PrintStyle::Args => {
for arg in args {
println!("{}", arg);
}
}
PrintStyle::Env => {
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use super::*;
use crate::{
BuilderUpdate, BundleFormat, Result,
serve::{AppServer, ServeUpdate, WebServer},
};
use anyhow::bail;
use dioxus_dx_wire_format::BuildStage;
/// Run the project with the given arguments
///
/// This is a shorthand for `dx serve` with interactive mode and hot-reload disa... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use super::*;
use crate::{AddressArguments, Anonymi<|fim_suffix|>ut().is_terminal() && self.interactive.unwrap_or(true)
}
}
impl Anonymized for ServeArgs {
fn anonymized(&self) -> Value {
json! {{
"address": self.address.anonymized(),
"open": self.open,
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use super::*;
use crate::{Result, cli};
use clap::CommandFactory;
use clap_complete::{Shell, generate};
use std::sync::atomic::AtomicBool;
/// Generate shell completions for the specified shell.
#[derive(Clone, Debug, Parser)]
pub(crate) struct ShellCompletions {
/// The shell to generate completions... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>/ Build in release mode [default: false]
#[clap(long, short, help_heading = HELP_HEADING)]
#[serde(default)]
pub(crate) release: bool,
/// The package to build
#[clap(short, long, help_heading = HELP_HEADING)]
pub(crate) package: Option<String>,
/// Build a specific binary [d... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use super::*;
use crate::{Result, StructuredOutput};
use anyhow::bail;
use dioxus_rsx::{BodyNode, CallBody, TemplateBody};
/// Translate some source file into Dioxus code
#[derive(Clone, Debug, Parser)]
pub(crate) struct Translate {
/// Activate debug mode
// short and long flags (-d, --debug) wi... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use super::*;
use crate::{Result, Workspace};
use anyhow::{Context, bail};
use itertools::Itertools;
use self_update::cargo_crate_version;
/// Run the project with the given arguments
///
/// This is a shorthand for `dx serve` with interactive mode and hot-reload disabled.
#[derive(Clone, Debug, Parser)]... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use clap::Parser;
use std::path::PathBuf;
#[derive(Parser, Clone, Debug, Default)]
pub struct Verbosity {
/// Use verbose output [default: false]
#[clap(long, global = true)]
pub(crate) verbose: bool,
/// Use trace output [default: false]
#[clap(long, global = true)]
pub(crate) t... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub(crate) struct ApplicationConfig {
/// Display name of the application
#[serde(default)]
pub(crate) name: Option<String>,
/// The... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>// for the full table.
#[serde(default)]
pub(crate) language: Option<u16>,
/// Pass the host Windows SDK's `um/` and `shared/` headers to `rc.exe` via
/// `/I` flags. Only relevant when cross-compiling to MSVC from a
/// non-Windows host where the SDK headers aren't on the default inc... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>) registry: ComponentRegistry,
/// The path where components are stored when adding or removing components
#[serde(default)]
pub(crate) components_dir: Option<PathBuf>,
}
<|fim_prefix|>use crate::component::ComponentRegistry;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use ... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>Android => BundlePlatform::Android,
crate::BundleFormat::MacOS => BundlePlatform::MacOS,
crate::BundleFormat::Windows => BundlePlatform::Windows,
crate::BundleFormat::Linux => BundlePlatform::Linux,
crate::BundleFormat::Web | crate::BundleFormat::Server => B... | fim | DioxusLabs/dioxus | rust |
//! Extract and merge inline Dioxus.toml configuration from Rust source files.
//!
//! This module allows examples and tests to embed configuration in their doc comments:
//!
//! ```rust
//! #![allow(unused)]
//! //! This example demonstrates iOS geolocation
//! //!
//! //! ```dioxus.toml
//! //! [bundle]
//! //! ident... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>//! Unified manifest configuration for cross-platform app packaging.
//!
//! This module provides configuration structs for permissions and platform-specific
//! manifest customization. Permissions declared here are automatically mapped to
//! platform-specific identifiers (AndroidManifest.xml, Info.plist... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>mains
for host in &deep_links.hosts {
self.ios_associated_domains.push(format!("applinks:{host}"));
}
// Store app link hosts for Android auto-verify intent filters
self.android_app_link_hosts = deep_links.hosts.clone();
// Add explicit Android intent ... | fim | DioxusLabs/dioxus | rust |
mod app;
mod bundle;
mod component;
mod dioxus_config;
mod inline_config;
mod manifest;
mod manifest_mapper;
mod serve;
mod web;
pub(crate) use app::*;
pub(crate) use bundle::*;
pub(crate) use dioxus_config::*;
pub(crate) use inline_config::*;
pub(crate) use manifest::*;
pub(crate) use manifest_mapper::*;
pub(crate) u... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>er" }),
})
}
}
<|fim_prefix|>use clap::Parser;
/// The arguments for the address the server will run on
#[derive(Clone, Debug, Default, Parser)]
pub(crate) struct AddressArguments {
/// The port the server will run on
#[clap(long)]
pub(crate) port: Option<u16>,
/// The addres... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> title: default_title(),
base_path: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub(crate) struct WebProxyConfig {
pub(crate) backend: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub(crate) struct WebWatcherConfig {
... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>ertain platforms that require it.
pub(crate) fn should_force_entropy() -> bool {
std::env::var("DIOXUS_FORCE_ENTRY").is_ok()
}
/// Should we test the installs?
#[allow(dead_code)] // -> used in tests only
pub(crate) fn test_installs() -> bool {
std::env::var("TEST_INSTALLS").is_ok()
}
<|fim_prefi... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>R");
pub const PKG_VERSION_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
pub const PKG_VERSION_PRE: &str = env!("CARGO_PKG_VERSION_PRE");
pub const GIT_COMMIT_HASH: Option<&str> = option_env!("DIOXUS_CLI_GIT_SHA");
pub const GIT_COMMIT_HASH_SHORT: Option<&str> = option_env!("DIOXUS_CLI_GIT_SHA_SHORT");
... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>YLE}{idx}{IDX_STYLE:#}: {}",
" ".repeat(padding),
cause
.to_string()
.lines()
.enumerate()
.map(|(idx, line)| {
if idx == 0 {
line.to_string()
} else {
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>//! esbuild binary download, caching, and invocation.
//!
//! esbuild is used for JavaScript bundling and minification, replacing the
//! previous SWC Rust library dependencies. The standalone Go binary is
//! downloaded from the npm registry and cached locally.
use crate::{CliSettings, Workspace};
use a... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>et mut ext = ext.to_os_string();
ext.push(".br");
ext
}
None => OsString::from("br"),
};
Some(path.with_extension(new_extension))
}
/// pre-compress a file with brotli
pub(crate) fn pre_compress_file(path: &Path) -> std::io::Result<()> {
let Some(compr... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>to_string(), json!({})),
Config::Schema { out } => ("config schema".to_string(), json!({ "out": out })),
Config::Set(setting) => (
format!("config set {}", setting),
match setting {
Setting::AlwaysOpenBrowser {... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>;
mod rustcwrapper;
mod serve;
mod settings;
mod tailwind;
mod test_harnesses;
mod wasm_bindgen;
mod wasm_opt;
mod workspace;
use std::process::ExitCode;
pub(crate) use build::*;
pub(crate) use cli::*;
pub(crate) use config::*;
pub(crate) use dioxus_dx_wire_format::*;
pub(crate) use error::*;
pub(crate)... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use std::{hash::Hasher, path::Path};
use anyhow::{Context, anyhow};
use codemap::SpanLoc;
use grass::OutputStyle;
use lightningcss::{
printer::PrinterOptions,
stylesheet::{MinifyOptions, ParserOptions, StyleSheet},
targets::{Browsers, Targets},
};
use manganis_core::{CssAssetOptions, CssModul... | fim | DioxusLabs/dioxus | rust |
use anyhow::Context;
use manganis::{AssetOptions, CssModuleAssetOptions, FolderAssetOptions};
use manganis_core::{AssetVariant, CssAssetOptions, ImageAssetOptions, JsAssetOptions};
use std::path::Path;
use crate::opt::css::{process_css_module, process_scss};
use super::{
css::process_css, folder::process_folder, ... | fim | DioxusLabs/dioxus | rust |
use std::path::Path;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use crate::opt::file::process_file_to;
/// Process a folder, optimizing and copying all assets into the output folder
pub fn process_folder(
source: &Path,
output_folder: &Path,
esbuild_path: Option<&Path>,
) -> anyhow::Re... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>//! Utilities for creating hashed paths to assets in Manganis. This module defines [`AssetHash`] which is used to create a hashed path to an asset in both the CLI and the macro.
use std::{
hash::{Hash, Hasher},
io::Read,
path::{Path, PathBuf},
};
use crate::opt::{
css::hash_scss,
fil... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>ed(5).unwrap();
liq.set_quality(0, 99).unwrap();
// Describe the bitmap
let mut img = liq.new_image(&bitmap[..], width, height, 0.0).unwrap();
// The magic happens in quantize()
let mut res = match liq.quantize(&mut img) {
Ok(res) => res,
Err(err) => panic!("Quantizat... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use std::path::Path;
use anyhow::Context;
use manganis_core::JsAssetOptions;
use crate::opt::hash::hash_file_contents;
pub(crate) fn process_js(
js_options: &JsAssetOptions,
source: &Path,
output_path: &Path,
esbuild_path: Option<&Path>,
) -> anyhow::Result<()> {
if js_options.minifi... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use std::{io::Read, path::Path};
use anyhow::Context;
pub(crate) fn minify_json(source: &str) -> anyhow::Result<String> {
// First try to parse the json
let json: serde_json::Value = serde_json::from_str(source)?;
// Then print it in a minified format
let json = serde_json::to_string(&js... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use manganis::SwiftPackageMetadata;
use manganis_core::{AndroidArtifactMetadata, BundledAsset};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashSet};
use std::path::{Path, PathBuf};
mod css;
mod file;
mod folder;
mod hash;
mod image;
mod js;
mod json;
pub(crate) use file::proce... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use anyhow::Result;
use clap::{Arg, ArgMatches, Args, FromArgMatches, arg};
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use std::str::FromStr;
use target_lexicon::{Environment, OperatingSystem, Triple};
#[derive(
Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserializ... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
env::{args, vars},
path::PathBuf,
process::ExitCode,
};
/// A "capture" of a workspace's rustc commands, cumulated by reading the various rustc commands
/// from disk.
#[derive(Clone, Debug, PartialEq)]
pub struct Works... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>difier::UNDERLINED) {
f.write_str("4;")?;
}
if modifier.contains(Modifier::SLOW_BLINK) {
f.write_str("5;")?;
}
if modifier.contains(Modifier::RAPID_BLINK) {
f.write_str("6;")?;
}
if modifier.contains(Modifier::REVERSED) {
f.write_str("7;")?;
}
... | fim | DioxusLabs/dioxus | rust |
use crate::{
AppBuilder, BuildId, BuildMode, BuilderUpdate, BundleFormat, Result, ServeArgs,
TraceController,
build::PatchError,
styles::{GLOW_STYLE, LINK_STYLE},
};
mod ansi_buffer;
mod output;
mod proxy;
mod proxy_ws;
mod runner;
mod server;
mod update;
use anyhow::bail;
use dioxus_dx_wire_format::B... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> Level::DEBUG => Style::new().blue(),
Level::TRACE => Style::new().blue(),
},
TraceSrc::Cargo => Style::new().yellow(),
TraceSrc::Build => Style::new().blue(),... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>handle.listening().await.unwrap().to_string()
}
async fn test_proxy_requests(path: String) {
let config = WebProxyConfig {
// Normally this would be an absolute URL including scheme/host/port,
// but in these tests we need to let the OS choose the port so tests
... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>::Request,
) -> Result<(), WsError> {
let (mut server_ws, _) = tokio_tungstenite::connect_async(proxied_request)
.await
.map_err(WsError::Connect)?;
let mut closed = false;
while !closed {
tokio::select! {
Some(server_msg) = server_ws.next() => {
... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>g, Clone)]
struct SharedStatus(Arc<RwLock<Status>>);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", content = "data")]
enum Status {
ClientInit {
application_name: String,
bundle: BundleFormat,
},
Building {
progress: f64,
buil... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>r {
id: BuildId,
},
Redraw,
TracingLog {
log: TraceMsg,
},
Exit {
error: Option<Error>,
},
}
<|fim_prefix|>use crate::{BuildId, BuilderUpdate, BundleFormat, Error, TraceMsg};
use axum::extract::ws::Message as WsMessage;
use std::path::PathBuf;
/// One fa... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::{Result, TraceSrc};
use anyhow::bail;
use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
use std::{fs, path::PathBuf, sync::Arc};
use tracing::{error, trace, warn};
/// Describes cli settings from project or global level.
/// The order of priority goes:
/// 1. CLI Flags/Arguments
//... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>self.get_binary_path()?;
// Download then extract tailwindcss.
let bytes = reqwest::get(url).await?.bytes().await?;
std::fs::create_dir_all(binary_path.parent().unwrap())
.context("failed to create tailwindcss directory")?;
std::fs::write(&binary_path, &bytes... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::{BuildTargets, BundleFormat, Cli, Commands, Workspace};
use anyhow::Result;
use clap::Parser;
use futures_util::{StreamExt, stream::FuturesUnordered};
use std::{
collections::HashSet,
fmt::Write,
path::{Path, PathBuf},
pin::Pin,
prelude::rust_2024::Future,
};
use target_lexi... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::{CliSettings, Result, Workspace};
use anyhow::{Context, anyhow};
use flate2::read::GzDecoder;
use std::path::{Path, PathBuf};
use tar::Archive;
use tempfile::TempDir;
use tokio::process::Command;
pub(crate) struct WasmBindgen {
version: String,
input_path: PathBuf,
out_dir: PathBuf... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>h(install_dir);
let lib_folder_name = "lib";
let installed_lib_path = install_dir.join(lib_folder_name);
// Create the lib and bin directories if they don't exist
for path in [installed_bin_path.parent(), Some(&installed_lib_path)]
.into_iter()
.flatten()
{
std... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> .map(|file| current_dir.join(file))
.find(|path| path.is_file());
// Try to find Dioxus.toml in the current directory
if let Some(new_config) = config {
dioxus_conf_file = Some(new_config.as_path().to_path_buf());
break;... | fim | DioxusLabs/dioxus | rust |
//! <div align="center">
//! <img
//! src="https://github.com/user-attachments/assets/6c7e227e-44ff-4e53-824a-67949051149c"
//! alt="Build web, desktop, and mobile apps with a single codebase."
//! width="100%"
//! class="darkmode-image"
//! >
//! </div>
//!
//! # Dioxus CLI conf... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>fn main() {
dioxus::launch(|| rsx! { "hello world!" })
}
<|fim_prefix|>use <|fim_middle|>dioxus::prelude::*;
<|endoftext|> | fim | DioxusLabs/dioxus | rust |
use dioxus::prelude::*;
fn main() {
dioxus::launch(|| rsx! { "hello world!" })
}
<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use dioxus::prelude<|fim_suffix|>rld!" })
}
<|fim_middle|>::*;
fn main() {
dioxus::launch(|| rsx! { "hello wo<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|><|fim_prefix|>use dioxus::prelude::*;
fn main() {
dioxus::<|fim_middle|>launch(|| rsx! { "hello world!" })
}
<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>us<|fim_suffix|>main() {
dioxus::launch(|| rsx! { "hello world!" })
}
<|fim_middle|>e dioxus::prelude::*;
fn <|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>llo world!" })
}
<|fim_prefix|>use diox<|fim_middle|>us::prelude::*;
fn main() {
dioxus::launch(|| rsx! { "he<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>d!" })
}
<|fim_prefix|>use dioxus<|fim_middle|>::prelude::*;
fn main() {
dioxus::launch(|| rsx! { "hello worl<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>!("Hello, world!");
}
<|fim_prefix|>fn main() {<|fim_middle|>
println<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use dioxus::prelude::*;
fn main() {
dioxus::la<|fim_suffix|> world!" })
}
<|fim_middle|>unch(|| rsx! { "hello<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>ld!");
}
<|fim_prefix|>fn <|fim_middle|>main() {
println!("Hello, wor<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> world!");
}
<|fim_prefix|>fn main() {
println!("<|fim_middle|>Hello,<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>fn main() {
println<|fim_suffix|>"Hello, world!");
}
<|fim_middle|>!(<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>u<|fim_suffix|>::launch(|| rsx! { "hello world!" })
}
<|fim_middle|>se dioxus::prelude::*;
fn main() {
dioxus<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>x! { "hello world!" })
}
<|fim_prefix|>use dioxus::prelude::*;
fn main() {
dioxus::launc<|fim_middle|>h(|| rs<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>
}
<|fim_prefix|>use dioxus::prelude::*;
fn main() {
<|fim_middle|> dioxus::launch(|| rsx! { "hello world!" })<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>
println!("Hello, world!");
}
<|fim_prefix|>fn ma<|fim_middle|>in() {<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>fn main() {<|fim_suffix|>intln!("Hello, world!");
}
<|fim_middle|>
pr<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>fn main() {
println<|fim_suffix|>orld!");
}
<|fim_middle|>!("Hello, w<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>fn main() {
<|fim_suffix|>"Hello, world!");
}
<|fim_middle|> println!(<|endoftext|> | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>y for TelemetryEventData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", serde_json::to_string(self).unwrap())
}
}
/// A serialized stack frame, in a format that matches PostHog's stack frame format.
///
/// Read more:
/// <https://github.com/PostHog... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> let mut cmd = Command::new("cargo");
cmd.arg("add");
match self {
CargoDependency::Simple(name) => {
cmd.arg(name);
}
CargoDependency::Detailed {
name,
version,
features,
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>#![doc = include_str!("../README.md")]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
macro_rules! defi... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>/// A macro for deciding whether or not to split the wasm bundle.
/// Used by the internal router-macro code. The c<|fim_suffix|>lit the wasm bundle.
/// Used by the internal router-macro code. The contents here are considered to be semver exempt.
///
/// Only on wasm with the wasm-split feature will we p... | fim | DioxusLabs/dioxus | rust |
use crate::*;
/// The layout for a constant sized array. The array layout is just a length and an item layout.
#[derive(Debug, Copy, Clone)]
pub struct ArrayLayout {
pub(crate) len: usize,
pub(crate) item_layout: &'static Layout,
}
impl ArrayLayout {
/// Create a new array layout
pub const fn new(len:... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>//! Const serialization utilities for the CBOR data format.
//!
//! ## Overview of the format
//!
//! Const serialize only supports a subset of the CBOR format, specifically the major types:
//! - UnsignedInteger
//! - NegativeInteger
//! - Bytes
//! - String
//! - Array
//!
//! Each item in CBOR starts w... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>/// A buffer that can be read from at compile time. This is very s<|fim_suffix|>elf.memory
}
/// Get a slice of the buffer from the current location to the end of the buffer
pub const fn remaining(&self) -> &[u8] {
self.memory.split_at(self.location).1
}
}
<|fim_middle|>imilar to ... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>#![allow(dead_code)]
use std::{fmt::Debug, hash::Hash, mem::MaybeUninit};
use crate::ConstReadBuffer;
const DEFAULT_MAX_SIZE: usize = 2usize.pow(10);
/// [`ConstVec`] is a version of [`Vec`] that is usable in const contexts. It has
/// a fixed maximum size, but it can grow and shrink within that size l... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::*;
/// Serialize an enum that is stored at the pointer passed in
pub(crate) const unsafe fn serialize_const_enum(
ptr: *const (),
mut to: ConstVec<u8>,
layout: &EnumLayout,
) -> ConstVec<u8> {
let byte_ptr = ptr as *const u8;
let discriminant = unsafe { layout.discriminant.... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
use std::mem::MaybeUninit;
mod const_buffers;
pub use const_buffers::ConstReadBuffer;
mod cbor;
mod const_vec;
mod r#enum;
pub use r#enum::*;
mod r#struct;
pub use r#struct::*;
mod primitive;
pub use primitive::*;
mod list;
pub use list::*;
m... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>he list
layout.len_layout.write(bytes.len() as u32, len_out);
let Some((_, data_out)) = out.split_at_mut_checked(layout.data_offset) else {
return None;
};
let mut offset = 0;
while offset < bytes.len() {
data_out[offset] = MaybeUninit::new(b... | fim | DioxusLabs/dioxus | rust |
use crate::*;
use std::mem::MaybeUninit;
/// The layout for a primitive type. The bytes will be reversed if the target is big endian.
#[derive(Debug, Copy, Clone)]
pub struct PrimitiveLayout {
pub(crate) size: usize,
}
impl PrimitiveLayout {
/// Create a new primitive layout
pub const fn new(size: usize) ... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::*;
use std::{char, fmt::Debug, hash::Hash, mem::MaybeUninit};
const MAX_STR_SIZE: usize = 256;
/// A string that is stored in a constant sized buffer that can be serialized and deserialized at compile time
#[derive(Clone, Copy)]
pub struct ConstStr {
bytes: [MaybeUninit<u8>; MAX_STR_SIZE]... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::*;
/// Plain old data for a field. Stores the offset of the field in the struct and the layout of the f<|fim_suffix|>uctLayout {
pub(crate) size: usize,
pub(crate) data: &'static [StructFieldLayout],
}
impl StructLayout {
/// Create a new struct layout
pub const fn new(size: u... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>nst)]
#[repr(C, u8)]
enum Initial {
A { a: u32, b: u8 },
}
#[derive(Debug, PartialEq, SerializeConst)]
#[repr(C, u8)]
enum New {
A { b: u8, a: u32, c: u32 },
}
let data = New::A {
a: 0x11111111,
b: 0x22,
c: 0x33333333,
};
le... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> d: Enum::B {
one: 0x44,
two: 0x555,
},
},
Struct {
a: 9,
b: 123,
c: 39,
d: Enum::B {
one: 0x46,
two: 0x555,
... | fim | DioxusLabs/dioxus | rust |
use const_serialize::{ConstVec, deserialize_const, serialize_const};
#[test]
fn test_serialize_const_layout_list() {
let mut buf = ConstVec::new();
buf = serialize_const(&[1u8, 2, 3] as &[u8; 3], buf);
println!("{:?}", buf.as_ref());
let buf = buf.as_ref();
assert_eq!(deserialize_const!([u8; 3], bu... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use const_serialize::{ConstVec, deserialize_const, serialize_const};
#[te<|fim_suffix|>);
let buf = buf.as_ref();
assert_eq!(deserialize_const!(u32, buf).unwrap().1, 1234u32);
let mut buf = ConstVec::new();
buf = serialize_const(&1234u64, buf);
let buf = buf.as_ref();
assert_eq!(... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>uf.as_ref();
assert!(buf.len() < 10);
let str = deserialize_const!(ConstStr, buf).unwrap().1;
assert_eq!(str.as_str(), "hello");
}
#[test]
fn test_serialize_const_layout_nested_str() {
let mut buf = ConstVec::new();
let str = ConstStr::new("hello");
buf = serialize_const(&[str, st... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use const_serialize::{ConstVec, SerializeConst, deserialize_const, serialize_const};
use std::mem::MaybeUninit;
#[test]
fn test_transmute_bytes_to_struct() {
struct MyStruct {
a: u32,
b: u8,
c: u32,
d: u32,
}
const SIZE: usize = std::mem::size_of::<MyStruct>();... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use const_serialize::{ConstVec, deserialize_const, serialize_const};
#[test]
fn test_serialize_const_layout_tuple() {
let mut buf = ConstVec::new();
buf = serialize_const(&(1234u32, 5678u16), buf);
let buf = buf.as_ref();
assert_eq!(
deserialize_co<|fim_suffix|>ssert_eq!(
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use proc_macro::TokenStream;
use quote::{ToTokens, quote};
use syn::{DeriveInput, LitInt, Path, parse_macro_input};
use syn::{Generics, WhereClause, WherePredicate, parse_quote};
fn add_bounds(where_clause: &mut Option<WhereClause>, generics: &Generics, krate: &Path) {
let bounds = generics.params.it... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>ker::PhantomData,
}
}
}
impl<F: ComponentFunction<P, M> + Clone, P: Clone + 'static, M: 'static> AnyProps
for VProps<F, P, M>
{
fn memoize(&mut self, other: &dyn Any) -> bool {
match other.downcast_ref::<P>() {
Some(other) => (self.memo)(&mut self.props, other),
... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::innerlude::ScopeOrder;
use crate::{ScopeId, virtual_dom::VirtualDom};
/// An Element's unique identifier.
///
/// `ElementId` is a `usize` that is unique across the entire VirtualDOM - but not unique across time. If a component is
/// unmounted, then the `ElementId` will be reused for a new co... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use std::{
any::TypeId,
ops::{Deref, DerefMut},
};
use crate::{
Element, SuspenseContext,
any_props::AnyProps,
innerlude::{
ElementRef, MountId, ScopeOrder, SuspenseBoundaryProps, SuspenseBoundaryPropsWithOwner,
VComponent, WriteMutations,
},
nodes::VNode,
... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>tes the longest list of new children that won't need to be moved.
5. Identify which nodes need to be removed
6. Identify which nodes will need to be diffed
7. Going along each item in the new list, create it and insert it before the next closest item in the LIS.
- if ... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>//! This module contains all the code for creating and diffing nodes.
//!
//! For suspense there are three different cases we need to handle:
//! - Creating nodes/scopes without mounting them
//! - Diffing nodes that are not mounted
//! - Mounted nodes that have already been created
//!
//! To support tho... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|>(new_nodes_on_stack));
// Restore the mount for the node we created
dom.set_mounted_dyn_node(mount, idx, new_mount);
}
};
}
/// Try to get the dynamic node and its index for a root node
pub(crate) fn get_dynamic_root_node_and_id(
&s... | fim | DioxusLabs/dioxus | rust |
<|fim_prefix|>use crate::innerlude::ScopeOrder;
use std::borrow::Borrow;
use std::cell::RefCell;
use std::collections::VecDeque;
/// Effects will always run after all changes to the DOM have be<|fim_suffix|> order,
effect: RefCell::new(effect),
}
}
pub(crate) fn push_back(&self, f: imp... | fim | DioxusLabs/dioxus | rust |
<|fim_suffix|> () {
fn into_value<F: FnOnce() -> T>(self, default: F) -> T {
default()
}
}
impl<T> ErrorBoundaryPropsBuilder_Optional<T> for (T,) {
fn into_value<F: FnOnce() -> T>(self, _: F) -> T {
self.0
}
}
#[allow(dead_code, non_camel_case_types, missing_docs)]
impl<__handle_error> E... | fim | DioxusLabs/dioxus | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.