aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-05-05 00:31:39 +0000
committerFuwn <[email protected]>2023-05-05 00:31:39 +0000
commit230dd1877f906708dc487bf5c4d87a8769b680fb (patch)
tree2ffe4537cf9e5c991e702e2528f56bdd4a5a16ac
parentdocs(readme): rossweisse info (diff)
downloadwindmark-230dd1877f906708dc487bf5c4d87a8769b680fb.tar.xz
windmark-230dd1877f906708dc487bf5c4d87a8769b680fb.zip
refactor: simplify imports
-rw-r--r--README.md2
-rw-r--r--examples/async_stateful_module.rs4
-rw-r--r--examples/struct_router.rs4
-rw-r--r--rossweisse/README.md4
-rw-r--r--rossweisse/src/implementations/router/fields.rs3
-rw-r--r--rossweisse/src/implementations/router/parser/field_initializer.rs2
-rw-r--r--rossweisse/src/implementations/router/parser/field_initializers.rs2
-rw-r--r--src/module/asynchronous.rs4
-rw-r--r--src/module/sync.rs4
-rw-r--r--src/router.rs2
10 files changed, 11 insertions, 20 deletions
diff --git a/README.md b/README.md
index 7bb13b2..fc7c523 100644
--- a/README.md
+++ b/README.md
@@ -40,8 +40,6 @@ tokio = { version = "1.26.0", features = ["full"] }
```rust
// src/main.rs
-use windmark::Response;
-
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
windmark::Router::new()
diff --git a/examples/async_stateful_module.rs b/examples/async_stateful_module.rs
index 3a2cb0a..3c35486 100644
--- a/examples/async_stateful_module.rs
+++ b/examples/async_stateful_module.rs
@@ -17,13 +17,11 @@
//! `cargo run --example async_stateful_module --features response-macros`
-use std::sync::{Arc, Mutex};
-
use windmark::{context::HookContext, Router};
#[derive(Default)]
struct Clicker {
- clicks: Arc<Mutex<usize>>,
+ clicks: std::sync::Arc<std::sync::Mutex<usize>>,
}
#[async_trait::async_trait]
diff --git a/examples/struct_router.rs b/examples/struct_router.rs
index a636f7d..af6bce9 100644
--- a/examples/struct_router.rs
+++ b/examples/struct_router.rs
@@ -17,8 +17,6 @@
//! `cargo run --example struct_router`
-use rossweisse::route;
-
#[rossweisse::router]
struct Router {
_phantom: (),
@@ -26,7 +24,7 @@ struct Router {
#[rossweisse::router]
impl Router {
- #[route(index)]
+ #[rossweisse::route(index)]
pub fn index(
_context: windmark::context::RouteContext,
) -> windmark::Response {
diff --git a/rossweisse/README.md b/rossweisse/README.md
index cbcf53a..117bff8 100644
--- a/rossweisse/README.md
+++ b/rossweisse/README.md
@@ -9,8 +9,6 @@ Rossweisse is in it's infancy, and a much comprehensive interface is planned.
For now, a simple Rosswiesse router can be implemented like this:
```rust
-use rossweisse::route;
-
#[rossweisse::router]
struct Router {
_phantom: (),
@@ -18,7 +16,7 @@ struct Router {
#[rossweisse::router]
impl Router {
- #[route(index)]
+ #[rossweisse::route(index)]
pub fn index(
_context: windmark::context::RouteContext,
) -> windmark::Response {
diff --git a/rossweisse/src/implementations/router/fields.rs b/rossweisse/src/implementations/router/fields.rs
index 697e0c1..a2d0bdf 100644
--- a/rossweisse/src/implementations/router/fields.rs
+++ b/rossweisse/src/implementations/router/fields.rs
@@ -17,10 +17,9 @@
use proc_macro::TokenStream;
use quote::quote;
-use syn::parse_macro_input;
pub fn fields(arguments: TokenStream, item: syn::ItemStruct) -> TokenStream {
- let field_initializers = parse_macro_input!(
+ let field_initializers = syn::parse_macro_input!(
arguments as super::parser::FieldInitializers<syn::Expr>
);
let router_identifier = item.ident;
diff --git a/rossweisse/src/implementations/router/parser/field_initializer.rs b/rossweisse/src/implementations/router/parser/field_initializer.rs
index ce0ff9d..0c92a30 100644
--- a/rossweisse/src/implementations/router/parser/field_initializer.rs
+++ b/rossweisse/src/implementations/router/parser/field_initializer.rs
@@ -24,7 +24,7 @@ pub struct FieldInitializer<T: Parse> {
pub expr: T,
}
-impl<T: Parse> parse::Parse for FieldInitializer<T> {
+impl<T: Parse> Parse for FieldInitializer<T> {
fn parse(input: parse::ParseStream<'_>) -> syn::Result<Self> {
let ident = input.parse()?;
let eq_token = input.parse()?;
diff --git a/rossweisse/src/implementations/router/parser/field_initializers.rs b/rossweisse/src/implementations/router/parser/field_initializers.rs
index e0eb4b9..00abf56 100644
--- a/rossweisse/src/implementations/router/parser/field_initializers.rs
+++ b/rossweisse/src/implementations/router/parser/field_initializers.rs
@@ -21,7 +21,7 @@ use super::field_initializer::FieldInitializer;
pub struct FieldInitializers<T: Parse>(pub Vec<FieldInitializer<T>>);
-impl<T: Parse> parse::Parse for FieldInitializers<T> {
+impl<T: Parse> Parse for FieldInitializers<T> {
fn parse(input: parse::ParseStream<'_>) -> syn::Result<Self> {
Ok(Self(syn::punctuated::Punctuated::<FieldInitializer<T>, syn::Token![,]>::parse_terminated(input)?.into_iter().collect()))
}
diff --git a/src/module/asynchronous.rs b/src/module/asynchronous.rs
index f94a0b6..2459518 100644
--- a/src/module/asynchronous.rs
+++ b/src/module/asynchronous.rs
@@ -15,12 +15,12 @@
// Copyright (C) 2022-2023 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use crate::{context::HookContext, Router};
+use crate::context::HookContext;
#[async_trait::async_trait]
pub trait AsyncModule: Send + Sync {
/// Called right after the module is attached.
- async fn on_attach(&mut self, _: &mut Router) {}
+ async fn on_attach(&mut self, _: &mut crate::Router) {}
/// Called before a route is mounted.
async fn on_pre_route(&mut self, _: HookContext) {}
diff --git a/src/module/sync.rs b/src/module/sync.rs
index 8c181be..4b6de4d 100644
--- a/src/module/sync.rs
+++ b/src/module/sync.rs
@@ -15,11 +15,11 @@
// Copyright (C) 2022-2023 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use crate::{context::HookContext, Router};
+use crate::context::HookContext;
pub trait Module {
/// Called right after the module is attached.
- fn on_attach(&mut self, _: &mut Router) {}
+ fn on_attach(&mut self, _: &mut crate::Router) {}
/// Called before a route is mounted.
fn on_pre_route(&mut self, _: HookContext) {}
diff --git a/src/router.rs b/src/router.rs
index 554651a..5532182 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -359,7 +359,7 @@ impl Router {
url = or_error!(
stream,
- url::Url::parse(&request.replace("\r\n", "")),
+ Url::parse(&request.replace("\r\n", "")),
"59 The server (Windmark) received a bad request: {}"
);