Skip to content

Commit 757990a

Browse files
committed
Cargo fmt
1 parent 7f5eebb commit 757990a

7 files changed

Lines changed: 39 additions & 38 deletions

File tree

crates/bindings-macro/src/procedure.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ fn parse_route_expr(expr: Expr) -> syn::Result<RouteAttr> {
5959
return Err(syn::Error::new_spanned(args, "expected a single path argument"));
6060
}
6161

62-
let Expr::Lit(ExprLit { lit: Lit::Str(path), .. }) = args.first().unwrap() else {
62+
let Expr::Lit(ExprLit {
63+
lit: Lit::Str(path), ..
64+
}) = args.first().unwrap()
65+
else {
6366
return Err(syn::Error::new_spanned(args, "expected a string literal path"));
6467
};
6568

@@ -129,7 +132,9 @@ pub(crate) fn procedure_impl(_args: ProcedureArgs, original_function: &ItemFn) -
129132
let lifetime_params = &original_function.sig.generics;
130133
let lifetime_where_clause = &lifetime_params.where_clause;
131134

132-
let (generated_describe_function, wrapper_fn, invoke_target, fn_kind_ty, return_type_ty) = if let Some(route) = route {
135+
let (generated_describe_function, wrapper_fn, invoke_target, fn_kind_ty, return_type_ty) = if let Some(route) =
136+
route
137+
{
133138
let RouteAttr { method, path } = route.clone();
134139
let method_str = method.to_string();
135140
let method_expr = match method_str.as_str() {
@@ -149,7 +154,10 @@ pub(crate) fn procedure_impl(_args: ProcedureArgs, original_function: &ItemFn) -
149154
let path_value = path.value();
150155
let valid_path = path_value.starts_with('/') && !path_value[1..].is_empty() && !path_value[1..].contains('/');
151156
if !valid_path {
152-
return Err(syn::Error::new_spanned(path, "route path must be a single segment starting with `/`"));
157+
return Err(syn::Error::new_spanned(
158+
path,
159+
"route path must be a single segment starting with `/`",
160+
));
153161
}
154162

155163
let wrapper_name = format_ident!("__spacetimedb_http_route_wrapper_{}", func_name);

crates/bindings/src/http.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ fn convert_response(response: st_http::Response) -> http::Result<http::response:
200200
}
201201

202202
#[doc(hidden)]
203-
pub fn request_and_body_to_http(
204-
request: st_http::RequestAndBody,
205-
) -> http::Result<http::Request<Body>> {
203+
pub fn request_and_body_to_http(request: st_http::RequestAndBody) -> http::Result<http::Request<Body>> {
206204
let st_http::RequestAndBody { request, body } = request;
207205
let parts = convert_request_from_st(request)?;
208206
Ok(http::Request::from_parts(parts, Body::from_bytes(body)))

crates/bindings/src/rt.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,8 @@ where
819819
I: FnInfo<Invoke = ProcedureFn>,
820820
{
821821
register_describer(move |module| {
822-
let params =
823-
<(spacetimedb_lib::http::RequestAndBody,) as Args>::schema::<I>(&mut module.inner);
824-
let ret_ty =
825-
<spacetimedb_lib::http::ResponseAndBody as SpacetimeType>::make_type(&mut module.inner);
822+
let params = <(spacetimedb_lib::http::RequestAndBody,) as Args>::schema::<I>(&mut module.inner);
823+
let ret_ty = <spacetimedb_lib::http::ResponseAndBody as SpacetimeType>::make_type(&mut module.inner);
826824
module.inner.add_procedure_with_visibility(
827825
I::NAME,
828826
params,

crates/client-api/src/routes/database.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ use axum::response::{ErrorResponse, IntoResponse};
2121
use axum::routing::MethodRouter;
2222
use axum::Extension;
2323
use axum_extra::TypedHeader;
24-
use http_body_util::BodyExt;
2524
use futures::TryStreamExt;
2625
use http::StatusCode;
26+
use http_body_util::BodyExt;
2727
use log::{info, warn};
2828
use serde::Deserialize;
2929
use spacetimedb::database_logger::DatabaseLogger;
@@ -41,12 +41,12 @@ use spacetimedb_client_api_messages::name::{
4141
};
4242
use spacetimedb_lib::db::raw_def::v10::RawModuleDefV10;
4343
use spacetimedb_lib::db::raw_def::v9::RawModuleDefV9;
44-
use spacetimedb_lib::{bsatn, http as st_http, sats, AlgebraicValue, Hash, ProductValue, Timestamp};
4544
use spacetimedb_lib::de as st_de;
45+
use spacetimedb_lib::sats::algebraic_value::de::ValueDeserializer;
46+
use spacetimedb_lib::{bsatn, http as st_http, sats, AlgebraicValue, Hash, ProductValue, Timestamp};
4647
use spacetimedb_schema::auto_migrate::{
4748
MigrationPolicy as SchemaMigrationPolicy, MigrationToken, PrettyPrintStyle as AutoMigratePrettyPrintStyle,
4849
};
49-
use spacetimedb_lib::sats::algebraic_value::de::ValueDeserializer;
5050

5151
use super::subscribe::{handle_websocket, HasWebSocketOptions};
5252

@@ -250,8 +250,12 @@ pub async fn http_route<S: ControlStateDelegate + NodeDelegate>(
250250
.to_bytes();
251251

252252
let request_and_body = convert_request_to_st(parts, body_bytes);
253-
let args = bsatn::to_vec(&request_and_body)
254-
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, format!("Failed to encode request: {err}")))?;
253+
let args = bsatn::to_vec(&request_and_body).map_err(|err| {
254+
(
255+
StatusCode::INTERNAL_SERVER_ERROR,
256+
format!("Failed to encode request: {err}"),
257+
)
258+
})?;
255259

256260
let call_result = module
257261
.call_procedure_internal(
@@ -269,8 +273,8 @@ pub async fn http_route<S: ControlStateDelegate + NodeDelegate>(
269273
Err(_) => return Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response()),
270274
};
271275

272-
let response = decode_response_and_body(result.return_val)
273-
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err))?;
276+
let response =
277+
decode_response_and_body(result.return_val).map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err))?;
274278

275279
let response = response_and_body_to_axum(response)
276280
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, format!("Invalid response: {err}")))?;

crates/lib/src/db/raw_def/v10.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,7 @@ impl RawModuleDefV10Builder {
10481048
params: ProductType,
10491049
return_type: AlgebraicType,
10501050
) {
1051-
self.add_procedure_with_visibility(
1052-
source_name,
1053-
params,
1054-
return_type,
1055-
FunctionVisibility::ClientCallable,
1056-
);
1051+
self.add_procedure_with_visibility(source_name, params, return_type, FunctionVisibility::ClientCallable);
10571052
}
10581053

10591054
/// Add a procedure to the in-progress module with explicit visibility.
@@ -1208,8 +1203,8 @@ impl TypespaceBuilder for RawModuleDefV10Builder {
12081203
// Alias provided? Relate `name -> slot_ref`.
12091204
let enum_source_name = if let Some(sats_name) = source_name {
12101205
let source_name = sats_name_to_scoped_name_v10(sats_name);
1211-
let enum_source_name = should_register_enum_variant_names(sats_name)
1212-
.then(|| source_name.source_name.clone());
1206+
let enum_source_name =
1207+
should_register_enum_variant_names(sats_name).then(|| source_name.source_name.clone());
12131208

12141209
self.types_mut().push(RawTypeDefV10 {
12151210
source_name,
@@ -1233,14 +1228,20 @@ impl TypespaceBuilder for RawModuleDefV10Builder {
12331228
let enum_variants = match (&enum_source_name, &self.typespace_mut()[slot_ref]) {
12341229
(Some(enum_source_name), AlgebraicType::Sum(sum)) => Some((
12351230
enum_source_name.clone(),
1236-
sum.variants.iter().filter_map(|variant| variant.name().cloned()).collect::<Vec<_>>(),
1231+
sum.variants
1232+
.iter()
1233+
.filter_map(|variant| variant.name().cloned())
1234+
.collect::<Vec<_>>(),
12371235
)),
12381236
_ => None,
12391237
};
12401238
if let Some((enum_source_name, variant_names)) = enum_variants {
12411239
for variant_name in variant_names {
1242-
self.explicit_names_mut()
1243-
.insert_enum_variant(enum_source_name.clone(), variant_name.clone(), variant_name);
1240+
self.explicit_names_mut().insert_enum_variant(
1241+
enum_source_name.clone(),
1242+
variant_name.clone(),
1243+
variant_name,
1244+
);
12441245
}
12451246
}
12461247
AlgebraicType::Ref(slot_ref)

crates/schema/src/def/validate/v10.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,7 @@ pub fn validate(def: RawModuleDefV10) -> Result<ModuleDef> {
287287
.cloned()
288288
.into_iter()
289289
.flatten()
290-
.map(|route| {
291-
validator.validate_http_route_def(route, &procedures, &expected_request_ty, &expected_response_ty)
292-
})
290+
.map(|route| validator.validate_http_route_def(route, &procedures, &expected_request_ty, &expected_response_ty))
293291
.collect_all_errors::<Vec<_>>()
294292
.map_err(|errors| errors.sort_deduplicate())?;
295293

crates/schema/src/def/validate/v9.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,7 @@ impl CoreValidator<'_> {
667667
for (index, ty) in typespace.types.iter_mut().enumerate() {
668668
let type_ref = AlgebraicTypeRef(index as u32);
669669
let enum_name = type_ref_names.get(&type_ref);
670-
Self::convert_algebraic_type(
671-
ty,
672-
case_policy,
673-
case_policy_for_enum_variants,
674-
enum_name,
675-
enum_variants,
676-
);
670+
Self::convert_algebraic_type(ty, case_policy, case_policy_for_enum_variants, enum_name, enum_variants);
677671
}
678672
}
679673

0 commit comments

Comments
 (0)