Skip to content

Commit

Permalink
fix fmt issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joinhack committed Aug 26, 2024
1 parent e3e7126 commit 34ef747
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions crates/apis/src/crypto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::Result;
use javy::{quickjs::JSValue, Runtime};
use javy::quickjs::{JSContextRef, JSValueRef};
use javy::{quickjs::JSValue, Runtime};

use rand::RngCore;
use crate::{APIConfig, JSApiSet};
use rand::RngCore;

pub struct Crypto;

Expand Down
6 changes: 3 additions & 3 deletions crates/apis/src/fetch_io/blockless.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]
use std::cmp::Ordering;
use serde_json::{json, Value};
use crate::fetch_io::FetchOptions;
use serde_json::{json, Value};
use std::cmp::Ordering;

pub type Handle = u32;

Expand Down Expand Up @@ -227,4 +227,4 @@ extern "C" {

#[link_name = "http_close"]
pub(crate) fn http_close(handle: u32) -> u32;
}
}
16 changes: 8 additions & 8 deletions crates/apis/src/fetch_io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#![allow(dead_code)]
mod blockless;

use std::collections::HashMap;
use anyhow::{anyhow, Result};
use javy::{quickjs::JSValue, Runtime};
use serde_json::{from_slice};
use serde::{Deserialize, Serialize};
use serde_json::from_slice;
use std::collections::HashMap;

use crate::fetch_io::blockless::BlocklessHttp;
use crate::{APIConfig, JSApiSet};
use javy::quickjs::{JSContextRef, JSValueRef};
use crate::fetch_io::blockless::BlocklessHttp;

pub(super) struct FetchIO;

Expand All @@ -21,17 +21,16 @@ pub struct FetchOptions {
impl FetchOptions {
pub fn new(method: &str) -> Self {
FetchOptions {
method: method.into()
method: method.into(),
}
}

#[allow(clippy::inherent_to_string)]
pub fn to_string(&self) -> String {
serde_json::to_string(&self).unwrap()
}
}


impl JSApiSet for FetchIO {
fn register(&self, runtime: &Runtime, _config: &APIConfig) -> Result<()> {
let context = runtime.context();
Expand All @@ -48,7 +47,8 @@ impl JSApiSet for FetchIO {
}
}

fn fetchio_request() -> impl FnMut(&JSContextRef, JSValueRef, &[JSValueRef]) -> anyhow::Result<JSValue> {
fn fetchio_request(
) -> impl FnMut(&JSContextRef, JSValueRef, &[JSValueRef]) -> anyhow::Result<JSValue> {
move |_ctx: &JSContextRef, _this: JSValueRef, args: &[JSValueRef]| {
if args.len() != 4 {
return Err(anyhow!("Expecting 4 arguments, received {}", args.len()));
Expand Down Expand Up @@ -80,4 +80,4 @@ fn fetchio_request() -> impl FnMut(&JSContextRef, JSValueRef, &[JSValueRef]) ->

Ok(JSValue::Object(response))
}
}
}
9 changes: 5 additions & 4 deletions crates/apis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,23 @@ use javy::Runtime;
pub use api_config::APIConfig;
#[cfg(feature = "console")]
pub use console::LogStream;

pub use runtime_ext::RuntimeExt;

mod api_config;
#[cfg(feature = "console")]
mod console;
#[cfg(feature = "crypto")]
mod crypto;
#[cfg(feature = "fetch_io")]
mod fetch_io;
#[cfg(feature = "random")]
mod random;
mod runtime_ext;
#[cfg(feature = "stream_io")]
mod stream_io;
#[cfg(feature = "text_encoding")]
mod text_encoding;
#[cfg(feature = "fetch_io")]
mod fetch_io;
#[cfg(feature = "crypto")]
mod crypto;

pub(crate) trait JSApiSet {
fn register(&self, runtime: &Runtime, config: &APIConfig) -> Result<()>;
Expand Down

0 comments on commit 34ef747

Please sign in to comment.