Skip to content

Commit b379cba

Browse files
style: run cargo fmt
1 parent 7b265c3 commit b379cba

1 file changed

Lines changed: 37 additions & 27 deletions

File tree

crates/runtime/src/parsers_ops.rs

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ fn value_to_json(v: Value) -> serde_json::Value {
9797
}
9898
}
9999

100-
101-
102100
/// Maximum element nesting accepted by the recursive XML reader. The parser
103101
/// descends one stack frame per level, so an unbounded document (`<a><a>…`)
104102
/// would otherwise overflow the stack and abort the process; past this depth we
@@ -423,13 +421,17 @@ pub(crate) fn install(engine: &mut dyn Engine) -> crate::Result<()> {
423421
let mut json_serializer = serde_json::Serializer::new(&mut out);
424422

425423
match serde_transcode::transcode(deserializer, &mut json_serializer) {
426-
Ok(_) => {
427-
match String::from_utf8(out) {
428-
Ok(json_str) => Ok(Value::String(json_str)),
429-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Invalid UTF-8 in JSON: {}", e))),
430-
}
431-
}
432-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Parse failed: {}", e))),
424+
Ok(_) => match String::from_utf8(out) {
425+
Ok(json_str) => Ok(Value::String(json_str)),
426+
Err(e) => Err(OpError::new(
427+
ExceptionClass::SyntaxError,
428+
format!("Invalid UTF-8 in JSON: {}", e),
429+
)),
430+
},
431+
Err(e) => Err(OpError::new(
432+
ExceptionClass::SyntaxError,
433+
format!("Parse failed: {}", e),
434+
)),
433435
}
434436
}))?;
435437

@@ -466,18 +468,20 @@ pub(crate) fn install(engine: &mut dyn Engine) -> crate::Result<()> {
466468
let mut json_serializer = serde_json::Serializer::new(&mut out);
467469

468470
match serde_transcode::transcode(deserializer, &mut json_serializer) {
469-
Ok(_) => {
470-
match String::from_utf8(out) {
471-
Ok(json_str) => Ok(Value::String(json_str)),
472-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Invalid UTF-8 in JSON: {}", e))),
473-
}
474-
}
475-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Parse failed: {}", e))),
471+
Ok(_) => match String::from_utf8(out) {
472+
Ok(json_str) => Ok(Value::String(json_str)),
473+
Err(e) => Err(OpError::new(
474+
ExceptionClass::SyntaxError,
475+
format!("Invalid UTF-8 in JSON: {}", e),
476+
)),
477+
},
478+
Err(e) => Err(OpError::new(
479+
ExceptionClass::SyntaxError,
480+
format!("Parse failed: {}", e),
481+
)),
476482
}
477483
}))?;
478484

479-
480-
481485
engine.register_op(OpDecl::sync("toml_validate", |args| {
482486
let toml_str = match args.first().and_then(Value::as_str) {
483487
Some(s) => s,
@@ -496,7 +500,9 @@ pub(crate) fn install(engine: &mut dyn Engine) -> crate::Result<()> {
496500

497501
// TOML requires the root to be an object (table)
498502
if !json_val.is_object() {
499-
return Err(OpError::type_error("TOML build requires the root to be an object"));
503+
return Err(OpError::type_error(
504+
"TOML build requires the root to be an object",
505+
));
500506
}
501507

502508
match toml::to_string(&json_val) {
@@ -515,15 +521,19 @@ pub(crate) fn install(engine: &mut dyn Engine) -> crate::Result<()> {
515521
// Pre-allocate buffer aiming for an average 2x size increase
516522
let mut out = Vec::with_capacity(msgpack_bytes.len() * 2);
517523
let mut json_serializer = serde_json::Serializer::new(&mut out);
518-
524+
519525
match serde_transcode::transcode(&mut deserializer, &mut json_serializer) {
520-
Ok(_) => {
521-
match String::from_utf8(out) {
522-
Ok(json_str) => Ok(Value::String(json_str)),
523-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Invalid UTF-8 in JSON: {}", e))),
524-
}
525-
}
526-
Err(e) => Err(OpError::new(ExceptionClass::SyntaxError, format!("Parse failed: {}", e))),
526+
Ok(_) => match String::from_utf8(out) {
527+
Ok(json_str) => Ok(Value::String(json_str)),
528+
Err(e) => Err(OpError::new(
529+
ExceptionClass::SyntaxError,
530+
format!("Invalid UTF-8 in JSON: {}", e),
531+
)),
532+
},
533+
Err(e) => Err(OpError::new(
534+
ExceptionClass::SyntaxError,
535+
format!("Parse failed: {}", e),
536+
)),
527537
}
528538
}))?;
529539

0 commit comments

Comments
 (0)