Skip to content

Commit 94f8222

Browse files
fix(deps): migrate to Dioxus v0.7.0-rc.3
1 parent 395ef00 commit 94f8222

13 files changed

Lines changed: 108 additions & 105 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
run: cargo binstall -y --force cargo-deny cargo-machete cargo-sort
3535

3636
- name: Lint
37-
run: cargo clippy --locked
37+
run: cargo clippy --all-features --all-targets --locked
3838

3939
- name: Check dependencies
4040
run: cargo deny check
4141

4242
- name: Check unused dependencies
43-
run: cargo machete
43+
run: cargo machete --with-metadata
4444

4545
- name: Check manifest formatting
4646
run: cargo sort --workspace --check

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repos:
1212
hooks:
1313
- id: fmt
1414
- id: clippy
15+
args: ['--all-targets', '--all-features', '--', '-D', 'warnings']
1516

1617
- repo: https://github.com/EmbarkStudios/cargo-deny
1718
rev: 0.18.5
@@ -28,6 +29,7 @@ repos:
2829
name: cargo-machete
2930
language: rust
3031
entry: cargo machete
32+
args: ['--with-metadata']
3133
types: [file, toml]
3234
files: Cargo\.(toml|lock)
3335
pass_filenames: false

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ actix-files = "0.6.6"
3333
actix-session = "0.11.0"
3434
actix-utils = "3.0.1"
3535
actix-web = "4.9.0"
36+
anyhow = "1.0.100"
3637
async-std = "1.13.0"
3738
async-trait = "0.1.83"
3839
axum = "0.8.1"
3940
bon = "3.3.2"
4041
chrono = "0.4.39"
4142
console_error_panic_hook = "0.1.2"
42-
dioxus = "0.7.0-rc.0"
43-
dioxus-html = "0.7.0-rc.0"
44-
dioxus-server = "0.7.0-rc.0"
43+
dioxus = "0.7.0-rc.3"
44+
dioxus-html = "0.7.0-rc.3"
45+
dioxus-server = "0.7.0-rc.3"
4546
futures = "0.3.31"
4647
http = "1.2.0"
4748
leptos = "0.8.3"

examples/dioxus-axum/src/main.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ fn main() {
1515
#[cfg(feature = "server")]
1616
#[tokio::main]
1717
async fn main() {
18-
use std::{env, sync::Arc};
18+
use std::sync::Arc;
1919

20-
use axum::Router;
20+
use axum::{Extension, Router};
2121
use dioxus::{
2222
cli_config::fullstack_address_or_localhost,
2323
prelude::{DioxusRouterExt, *},
2424
};
25-
use shield::{ErasedMethod, Method, Shield, ShieldOptions};
25+
use shield::{Shield, ShieldOptions};
2626
use shield_bootstrap::BootstrapDioxusStyle;
2727
use shield_dioxus_axum::{AuthRoutes, AxumDioxusIntegration, ShieldLayer};
2828
use shield_memory::{MemoryStorage, User};
@@ -66,15 +66,14 @@ async fn main() {
6666

6767
// Initialize router
6868
let router = Router::new()
69-
.nest("/api/auth", AuthRoutes::router::<User, ()>())
69+
.nest("/api/auth", AuthRoutes::new(shield).router())
7070
.serve_dioxus_application(
71-
ServeConfig::builder()
72-
.context(AxumDioxusIntegration::<User>::default().context())
73-
.context(BootstrapDioxusStyle::default().context())
74-
.build()
75-
.unwrap(),
71+
ServeConfig::new().context(BootstrapDioxusStyle::default().context()),
7672
App,
7773
)
74+
.layer(Extension(
75+
AxumDioxusIntegration::<User>::default().context(),
76+
))
7877
.layer(shield_layer)
7978
.layer(session_layer);
8079

examples/workos/src/main.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ fn main() {
1717
async fn main() {
1818
use std::{env, sync::Arc};
1919

20-
use axum::Router;
20+
use axum::{Extension, Router};
2121
use dioxus::{
2222
cli_config::fullstack_address_or_localhost,
2323
prelude::{DioxusRouterExt, *},
2424
};
25-
use shield::{ErasedMethod, Method, Shield, ShieldOptions};
25+
use shield::{Shield, ShieldOptions};
2626
use shield_bootstrap::BootstrapDioxusStyle;
2727
use shield_dioxus_axum::{AxumDioxusIntegration, ShieldLayer};
2828
use shield_memory::{MemoryStorage, User};
@@ -69,13 +69,12 @@ async fn main() {
6969
// Initialize router
7070
let router = Router::new()
7171
.serve_dioxus_application(
72-
ServeConfig::builder()
73-
.context(AxumDioxusIntegration::<User>::default().context())
74-
.context(BootstrapDioxusStyle::default().context())
75-
.build()
76-
.unwrap(),
72+
ServeConfig::new().context(BootstrapDioxusStyle::default().context()),
7773
App,
7874
)
75+
.layer(Extension(
76+
AxumDioxusIntegration::<User>::default().context(),
77+
))
7978
.layer(shield_layer)
8079
.layer(session_layer);
8180

packages/core/shield/src/shield.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ use utoipa::{
1313
},
1414
};
1515

16+
#[cfg(feature = "utoipa")]
17+
use crate::path::ActionPathParams;
1618
use crate::{
1719
action::{ActionForms, ActionMethodForm, ActionProviderForm},
1820
error::{ActionError, MethodError, ProviderError, SessionError, ShieldError},
1921
method::ErasedMethod,
2022
options::ShieldOptions,
21-
path::ActionPathParams,
2223
request::Request,
2324
response::ResponseType,
2425
session::Session,

packages/integrations/shield-dioxus-axum/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default = []
1313
utoipa = ["shield-axum/utoipa"]
1414

1515
[dependencies]
16-
async-trait.workspace = true
16+
anyhow.workspace = true
1717
dioxus-server.workspace = true
1818
shield.workspace = true
1919
shield-axum.workspace = true
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::marker::PhantomData;
22

3-
use async_trait::async_trait;
4-
use dioxus_server::extract;
5-
6-
use shield::{Session, ShieldDyn, User};
3+
use anyhow::{Result, anyhow};
4+
use dioxus_server::http::Extensions;
5+
use shield::{Session, Shield, ShieldDyn, User};
76
use shield_axum::{ExtractSession, ExtractShield};
87
use shield_dioxus::{DioxusIntegration, DioxusIntegrationDyn};
98

@@ -21,19 +20,24 @@ impl<U: User> Default for AxumDioxusIntegration<U> {
2120
}
2221
}
2322

24-
#[async_trait]
2523
impl<U: User + Clone + 'static> DioxusIntegration for AxumDioxusIntegration<U> {
26-
async fn extract_shield(&self) -> ShieldDyn {
27-
let ExtractShield(shield) = extract::<ExtractShield<U>, _>()
28-
.await
29-
.expect("Shield should be extracted");
30-
31-
ShieldDyn::new(shield)
24+
fn extract_shield(&self, extensions: &Extensions) -> Result<ShieldDyn> {
25+
let ExtractShield(shield) = extensions
26+
.get::<Shield<U>>()
27+
.cloned()
28+
.map(ExtractShield)
29+
.ok_or_else(|| anyhow!("Shield should be extracted"))?;
30+
31+
Ok(ShieldDyn::new(shield))
3232
}
3333

34-
async fn extract_session(&self) -> Session {
35-
let ExtractSession(session) = extract().await.expect("Session should be extracted");
34+
fn extract_session(&self, extensions: &Extensions) -> Result<Session> {
35+
let ExtractSession(session) = extensions
36+
.get::<Session>()
37+
.cloned()
38+
.map(ExtractSession)
39+
.ok_or_else(|| anyhow!("Session should be extracted"))?;
3640

37-
session
41+
Ok(session)
3842
}
3943
}

packages/integrations/shield-dioxus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ version.workspace = true
1212
server = ["dioxus/server"]
1313

1414
[dependencies]
15-
async-trait.workspace = true
15+
anyhow.workspace = true
1616
dioxus = { workspace = true, features = ["fullstack", "router"] }
1717
serde_json.workspace = true
1818
shield.workspace = true

0 commit comments

Comments
 (0)