Skip to content

Commit

Permalink
fmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfuze committed May 3, 2024
1 parent ada66c8 commit f06c0a3
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 57 deletions.
6 changes: 1 addition & 5 deletions c/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::{
ffi::{c_void, CStr},
os::raw::c_char,
sync::Arc,
};
use std::{ffi::CStr, os::raw::c_char, sync::Arc};

use longportwhale::Config;

Expand Down
2 changes: 1 addition & 1 deletion java/src/init.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::types::ClassLoader;
use jni::{
descriptors::Desc,
objects::{GlobalRef, JClass, JValue},
JNIEnv,
};
use once_cell::sync::OnceCell;
use crate::types::ClassLoader;

pub(crate) static LONG_CLASS: OnceCell<GlobalRef> = OnceCell::new();
pub(crate) static STRING_CLASS: OnceCell<GlobalRef> = OnceCell::new();
Expand Down
1 change: 0 additions & 1 deletion java/src/types/enum_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ impl_java_enum!(
longportwhale::trade::TopicType,
[Private]
);

4 changes: 3 additions & 1 deletion nodejs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ impl Config {
/// - `LONGPORT_TRADE_WS_URL` - Trade websocket endpoint url
#[napi(factory)]
pub fn from_env() -> Result<Self> {
Ok(Self(longportwhale::Config::from_env().map_err(ErrorNewType)?))
Ok(Self(
longportwhale::Config::from_env().map_err(ErrorNewType)?,
))
}
}
1 change: 0 additions & 1 deletion nodejs/src/trade/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,3 @@ pub struct PushOrderChanged {
/// Remark message
remark: String,
}

4 changes: 3 additions & 1 deletion python/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ impl Config {

#[classmethod]
fn from_env(_cls: &PyType) -> PyResult<Self> {
Ok(Self(longportwhale::Config::from_env().map_err(ErrorNewType)?))
Ok(Self(
longportwhale::Config::from_env().map_err(ErrorNewType)?,
))
}
}
5 changes: 1 addition & 4 deletions python/src/trade/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use pyo3::{pyclass, pymethods, PyObject, PyResult, Python};
use crate::{
config::Config,
error::ErrorNewType,
trade::{
push::handle_push_event,
types::TopicType,
},
trade::{push::handle_push_event, types::TopicType},
};

#[derive(Debug, Default)]
Expand Down
7 changes: 1 addition & 6 deletions python/src/trade/types.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use longportwhale_python_macros::{PyEnum, PyObject};
use pyo3::pyclass;

use crate::{
decimal::PyDecimal,
time::PyOffsetDateTimeWrapper,
};
use crate::{decimal::PyDecimal, time::PyOffsetDateTimeWrapper};

/// Topic type
#[pyclass]
Expand Down Expand Up @@ -211,5 +208,3 @@ pub(crate) struct PushOrderChanged {
/// Remark message
remark: String,
}


2 changes: 1 addition & 1 deletion rust/crates/httpclient/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{HttpClientError};
use crate::HttpClientError;

const HTTP_URL: &str = "https://api.longbridgewhale.com";

Expand Down
4 changes: 1 addition & 3 deletions rust/src/blocking/trade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::sync::Arc;

use crate::{
blocking::runtime::BlockingRuntime,
trade::{
PushEvent, TopicType, TradeContext,
},
trade::{PushEvent, TopicType, TradeContext},
Config, Result,
};

Expand Down
6 changes: 2 additions & 4 deletions rust/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ impl Config {
let _ = dotenv::dotenv();

let http_cli_config = HttpClientConfig::from_env()?;
let trade_ws_url = std::env::var("LONGPORT_TRADE_WS_URL")
.unwrap_or_else(|_| {
TRADE_WS_URL.to_string()
});
let trade_ws_url =
std::env::var("LONGPORT_TRADE_WS_URL").unwrap_or_else(|_| TRADE_WS_URL.to_string());

Ok(Config {
http_cli_config,
Expand Down
1 change: 0 additions & 1 deletion rust/src/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ pub(crate) mod date_opt {
}
}


pub(crate) mod decimal_empty_is_0 {
use rust_decimal::Decimal;

Expand Down
7 changes: 1 addition & 6 deletions rust/src/trade/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ impl TradeContext {
let (command_tx, command_rx) = mpsc::unbounded_channel();
let (push_tx, push_rx) = mpsc::unbounded_channel();
tokio::spawn(Core::try_new(config, command_rx, push_tx).await?.run());
Ok((
TradeContext {
command_tx,
},
push_rx,
))
Ok((TradeContext { command_tx }, push_rx))
}

/// Subscribe
Expand Down
4 changes: 1 addition & 3 deletions rust/src/trade/core.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::{collections::HashSet, sync::Arc, time::Duration};


use longport_proto::trade::{Sub, SubResponse, Unsub, UnsubResponse};
use longportwhale_httpcli::HttpClient;
use longportwhale_wscli::{
CodecType, Platform, ProtocolVersion, WsClient, WsClientError, WsEvent, WsSession,
};
use std::{collections::HashSet, sync::Arc, time::Duration};
use tokio::sync::{mpsc, oneshot};

use crate::{
Expand Down
4 changes: 1 addition & 3 deletions rust/src/trade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ mod types;

pub use context::TradeContext;
pub use push_types::{PushEvent, PushOrderChanged, TopicType};
pub use types::{
OrderSide, OrderStatus, OrderTag, OrderType, TriggerStatus,
};
pub use types::{OrderSide, OrderStatus, OrderTag, OrderType, TriggerStatus};
18 changes: 2 additions & 16 deletions rust/src/trade/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,6 @@ pub enum TriggerStatus {
Released,
}

impl_serde_for_enum_string!(OrderType, OrderStatus, OrderSide, OrderTag, TriggerStatus);


impl_serde_for_enum_string!(
OrderType,
OrderStatus,
OrderSide,
OrderTag,
TriggerStatus
);

impl_default_for_enum_string!(
OrderType,
OrderStatus,
OrderSide,
OrderTag,
TriggerStatus
);
impl_default_for_enum_string!(OrderType, OrderStatus, OrderSide, OrderTag, TriggerStatus);

0 comments on commit f06c0a3

Please sign in to comment.