Skip to content

Commit d5ef97d

Browse files
committed
Clean the mfs!
1 parent b3e69e3 commit d5ef97d

9 files changed

Lines changed: 43 additions & 52 deletions

File tree

crates/cargo-rustapi/src/commands/watch.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,7 @@ pub async fn watch(args: WatchArgs) -> Result<()> {
212212
style("Watching:").bold(),
213213
args.watch_paths.join(", ")
214214
);
215-
println!(
216-
"{} {} {}ms",
217-
WATCH,
218-
style("Debounce:").bold(),
219-
args.delay
220-
);
215+
println!("{} {} {}ms", WATCH, style("Debounce:").bold(), args.delay);
221216
println!();
222217
println!("{}", style("Press Ctrl+C to stop.").dim());
223218
println!();
@@ -454,10 +449,7 @@ mod tests {
454449
&ignore
455450
));
456451
assert!(is_ignored(std::path::Path::new(".git/HEAD"), &ignore));
457-
assert!(!is_ignored(
458-
std::path::Path::new("src/main.rs"),
459-
&ignore
460-
));
452+
assert!(!is_ignored(std::path::Path::new("src/main.rs"), &ignore));
461453
}
462454

463455
#[test]

crates/rustapi-core/src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,7 @@ impl RustApi {
999999
if is_under_watcher {
10001000
tracing::info!(" File watcher active — changes will trigger rebuild + restart");
10011001
} else {
1002-
tracing::info!(
1003-
" Tip: Run with `cargo rustapi run --watch` for automatic hot-reload"
1004-
);
1002+
tracing::info!(" Tip: Run with `cargo rustapi run --watch` for automatic hot-reload");
10051003
}
10061004

10071005
tracing::info!(" Listening on http://{addr}");
@@ -1111,7 +1109,9 @@ impl RustApi {
11111109
};
11121110

11131111
let server = Server::new(self.router, self.layers, self.interceptors);
1114-
server.run_with_shutdown(addr.as_ref(), wrapped_signal).await
1112+
server
1113+
.run_with_shutdown(addr.as_ref(), wrapped_signal)
1114+
.await
11151115
}
11161116

11171117
/// Get the inner router (for testing or advanced usage)

crates/rustapi-core/src/hateoas.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ impl<T: Serialize> Paginated<T> {
596596
let total_pages = self.total_pages();
597597

598598
let links = PaginationLinks {
599-
self_link: format!("{}?page={}&per_page={}", base_path, self.page, self.per_page),
599+
self_link: format!(
600+
"{}?page={}&per_page={}",
601+
base_path, self.page, self.per_page
602+
),
600603
first: format!("{}?page=1&per_page={}", base_path, self.per_page),
601604
last: format!(
602605
"{}?page={}&per_page={}",
@@ -662,21 +665,18 @@ impl<T: Serialize + Send> crate::response::IntoResponse for Paginated<T> {
662665
if !link_header.is_empty() {
663666
response.headers_mut().insert(
664667
http::header::LINK,
665-
http::HeaderValue::from_str(&link_header).unwrap_or_else(|_| {
666-
http::HeaderValue::from_static("")
667-
}),
668+
http::HeaderValue::from_str(&link_header)
669+
.unwrap_or_else(|_| http::HeaderValue::from_static("")),
668670
);
669671
}
670672

671673
response
672674
}
673-
Err(err) => {
674-
crate::error::ApiError::internal(format!(
675-
"Failed to serialize paginated response: {}",
676-
err
677-
))
678-
.into_response()
679-
}
675+
Err(err) => crate::error::ApiError::internal(format!(
676+
"Failed to serialize paginated response: {}",
677+
err
678+
))
679+
.into_response(),
680680
}
681681
}
682682
}
@@ -758,13 +758,11 @@ impl<T: Serialize + Send> crate::response::IntoResponse for CursorPaginated<T> {
758758
.header(http::header::CONTENT_TYPE, "application/json")
759759
.body(crate::response::Body::from(json_bytes))
760760
.unwrap(),
761-
Err(err) => {
762-
crate::error::ApiError::internal(format!(
763-
"Failed to serialize cursor-paginated response: {}",
764-
err
765-
))
766-
.into_response()
767-
}
761+
Err(err) => crate::error::ApiError::internal(format!(
762+
"Failed to serialize cursor-paginated response: {}",
763+
err
764+
))
765+
.into_response(),
768766
}
769767
}
770768
}

crates/rustapi-core/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ pub use handler::{
113113
RouteHandler,
114114
};
115115
pub use hateoas::{
116-
CursorPaginated, Link, LinkOrArray, Linkable, PageInfo, Paginated, Resource,
117-
ResourceCollection,
116+
CursorPaginated, Link, LinkOrArray, Linkable, PageInfo, Paginated, Resource, ResourceCollection,
118117
};
119118
pub use health::{HealthCheck, HealthCheckBuilder, HealthCheckResult, HealthStatus};
120119
pub use http::StatusCode;

crates/rustapi-extras/src/cache/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ impl CacheStore {
144144
.iter()
145145
.filter(|entry| {
146146
// Cache keys are "METHOD:URI", check the URI part
147-
entry.key().split_once(':').map_or(false, |(_, uri)| uri.starts_with(prefix))
147+
entry
148+
.key()
149+
.split_once(':')
150+
.map_or(false, |(_, uri)| uri.starts_with(prefix))
148151
})
149152
.map(|entry| entry.key().clone())
150153
.collect();
@@ -411,17 +414,13 @@ impl MiddlewareLayer for CacheLayer {
411414
if let Some(entry) = store.get(&key) {
412415
if entry.created_at.elapsed() < config.ttl {
413416
// ETag: return 304 Not Modified if client has the same ETag
414-
if let (Some(ref etag), Some(ref client_etag)) =
415-
(&entry.etag, &if_none_match)
416-
{
417+
if let (Some(ref etag), Some(ref client_etag)) = (&entry.etag, &if_none_match) {
417418
if etag == client_etag {
418419
return http::Response::builder()
419420
.status(http::StatusCode::NOT_MODIFIED)
420421
.header("ETag", etag.as_str())
421422
.header("X-Cache", "HIT")
422-
.body(ResponseBody::Full(http_body_util::Full::new(
423-
Bytes::new(),
424-
)))
423+
.body(ResponseBody::Full(http_body_util::Full::new(Bytes::new())))
425424
.unwrap();
426425
}
427426
}
@@ -623,7 +622,10 @@ mod tests {
623622
assert_eq!(layer.config.ttl, Duration::from_secs(120));
624623
assert_eq!(layer.config.max_entries, 500);
625624
assert!(layer.config.skip_paths.contains(&"/debug".to_string()));
626-
assert!(layer.config.vary_headers.contains(&"accept-language".to_string()));
625+
assert!(layer
626+
.config
627+
.vary_headers
628+
.contains(&"accept-language".to_string()));
627629
assert!(!layer.config.etag);
628630
assert!(handle.is_empty());
629631
}

crates/rustapi-macros/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ fn generate_route_handler(method: &str, attr: TokenStream, item: TokenStream) ->
739739
if i + 2 < tokens.len() {
740740
if let proc_macro2::TokenTree::Punct(p) = &tokens[i + 1] {
741741
if p.as_char() == '=' {
742-
if let proc_macro2::TokenTree::Literal(desc_lit) = &tokens[i + 2] {
742+
if let proc_macro2::TokenTree::Literal(desc_lit) =
743+
&tokens[i + 2]
744+
{
743745
let desc_str = desc_lit.to_string();
744746
// Remove surrounding quotes
745747
let desc = desc_str.trim_matches('"').to_string();
@@ -749,7 +751,9 @@ fn generate_route_handler(method: &str, attr: TokenStream, item: TokenStream) ->
749751
i += 3;
750752
// Skip comma
751753
if i < tokens.len() {
752-
if let proc_macro2::TokenTree::Punct(p) = &tokens[i] {
754+
if let proc_macro2::TokenTree::Punct(p) =
755+
&tokens[i]
756+
{
753757
if p.as_char() == ',' {
754758
i += 1;
755759
}

crates/rustapi-rs/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub mod __private {
2222
pub mod core {
2323
pub use rustapi_core::collect_auto_routes;
2424
pub use rustapi_core::validation::Validatable;
25+
pub use rustapi_core::EventBus;
2526
pub use rustapi_core::{
2627
delete, delete_route, get, get_route, patch, patch_route, post, post_route, put, put_route,
2728
route, serve_dir, sse_response, ApiError, AsyncValidatedJson, Body, BodyLimitLayer,
@@ -33,7 +34,6 @@ pub mod core {
3334
RustApi, RustApiConfig, Sse, SseEvent, State, StaticFile, StaticFileConfig, StatusCode,
3435
StreamBody, TracingLayer, Typed, TypedPath, UploadedFile, ValidatedJson, WithStatus,
3536
};
36-
pub use rustapi_core::EventBus;
3737

3838
pub use rustapi_core::get_environment;
3939

@@ -271,6 +271,7 @@ pub use rustapi_extras::timeout;
271271

272272
/// Prelude module: `use rustapi_rs::prelude::*`.
273273
pub mod prelude {
274+
pub use crate::core::EventBus;
274275
pub use crate::core::Validatable;
275276
pub use crate::core::{
276277
delete, delete_route, get, get_route, patch, patch_route, post, post_route, put, put_route,
@@ -282,7 +283,6 @@ pub mod prelude {
282283
StaticFileConfig, StatusCode, StreamBody, TracingLayer, Typed, TypedPath, UploadedFile,
283284
ValidatedJson, WithStatus,
284285
};
285-
pub use crate::core::EventBus;
286286

287287
#[cfg(any(feature = "core-compression", feature = "compression"))]
288288
pub use crate::core::{CompressionAlgorithm, CompressionConfig, CompressionLayer};

crates/rustapi-rs/tests/sprint3_hot_reload_test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ fn hot_reload_with_full_config() {
2828
"hello"
2929
}
3030

31-
let _app = RustApi::new()
32-
.hot_reload(true)
33-
.route("/", get(hello));
31+
let _app = RustApi::new().hot_reload(true).route("/", get(hello));
3432
}

crates/rustapi-rs/tests/typed_errors_test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ fn test_correct_extractor_order_compiles() {
140140
// If this test compiles and runs, it means correct extractor ordering passes
141141
let routes = rustapi_rs::collect_auto_routes();
142142
assert!(
143-
routes
144-
.iter()
145-
.any(|r| r.path() == "/extractor-order-ok"),
143+
routes.iter().any(|r| r.path() == "/extractor-order-ok"),
146144
"Route with correct extractor order should exist"
147145
);
148146
}

0 commit comments

Comments
 (0)