Skip to content

Commit

Permalink
Apply rustfmt's option group_imports=StdExternalCrate (#119)
Browse files Browse the repository at this point in the history
Close: #118
  • Loading branch information
kimhanbeom authored Jun 11, 2024
1 parent bc6a43d commit 0cb180b
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
components: clippy, rustfmt
- name: Check formatting
run: cargo fmt -- --check
run: cargo fmt -- --check --config group_imports=StdExternalCrate
- name: Clippy
run: cargo clippy -- -D warnings -W clippy::pedantic
- name: markdownlint
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Changed

- Modified connection log structure to include total L2 frame length of a session.
- Apply rustfmt's option `group_imports=StdExternalCrate`.
- Modify the code with the command `cargo fmt -- --config group_imports=StdExternalCrate`.
This command must be applied automatically or manually before all future pull
requests are submitted.
- Add `--config group_imports=StdExternalCrate` to the CI process like:
- `cargo fmt -- --check --config group_imports=StdExternalCrate`

## [0.17.0] - 2024-05-16

Expand Down
3 changes: 2 additions & 1 deletion src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Functions and errors for handling messages.

use crate::frame::{self, recv_handshake, send_handshake, RecvError, SendError};
use quinn::{Connection, ConnectionError, RecvStream, SendStream};
use semver::{Version, VersionReq};
use thiserror::Error;

use crate::frame::{self, recv_handshake, send_handshake, RecvError, SendError};

/// The error type for a handshake failure.
#[derive(Debug, Error)]
pub enum HandshakeError {
Expand Down
3 changes: 2 additions & 1 deletion src/frame.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Functions and errors for handling length-delimited frames.

use std::{mem, num::TryFromIntError};

use quinn::{RecvStream, SendStream};
use serde::{Deserialize, Serialize};
use std::{mem, num::TryFromIntError};
use thiserror::Error;

/// The error type for receiving and deserializing a frame.
Expand Down
8 changes: 5 additions & 3 deletions src/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ pub mod timeseries;

use std::fmt::Display;

use crate::frame::{self, RecvError, SendError};
use crate::RawEventKind;
use quinn::{RecvStream, SendStream};
use serde::{Deserialize, Serialize};

use crate::frame::{self, RecvError, SendError};
use crate::RawEventKind;

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Packet {
pub packet_timestamp: i64,
Expand Down Expand Up @@ -136,9 +137,10 @@ fn to_string_or_empty<T: Display>(option: Option<T>) -> String {
mod tests {
#[tokio::test]
async fn ingest_send_recv() {
use crate::test::{channel, TOKEN};
use std::{mem, net::IpAddr};

use crate::test::{channel, TOKEN};

let _lock = TOKEN.lock().await;
let mut channel = channel().await;

Expand Down
8 changes: 5 additions & 3 deletions src/ingest/log.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::{ingest::to_string_or_empty, publish::range::ResponseRangeData};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::{
fmt::{Display, Formatter},
net::IpAddr,
};

use anyhow::Result;
use serde::{Deserialize, Serialize};

use crate::{ingest::to_string_or_empty, publish::range::ResponseRangeData};

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Log {
pub kind: String,
Expand Down
6 changes: 4 additions & 2 deletions src/ingest/netflow.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::{ingest::convert_time_format, publish::range::ResponseRangeData};
use serde::{Deserialize, Serialize};
use std::{
fmt::{Display, Formatter},
net::IpAddr,
};

use serde::{Deserialize, Serialize};

use crate::{ingest::convert_time_format, publish::range::ResponseRangeData};

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[allow(clippy::module_name_repetitions)]
pub struct Netflow5 {
Expand Down
14 changes: 8 additions & 6 deletions src/ingest/network.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::{
ingest::{as_str_or_default, convert_time_format, vec_to_string_or_default},
publish::range::ResponseRangeData,
use std::{
fmt::{Display, Formatter},
net::IpAddr,
};

use anyhow::Result;
use num_enum::FromPrimitive;
use serde::{Deserialize, Serialize};
use std::{
fmt::{Display, Formatter},
net::IpAddr,

use crate::{
ingest::{as_str_or_default, convert_time_format, vec_to_string_or_default},
publish::range::ResponseRangeData,
};

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
Expand Down
6 changes: 4 additions & 2 deletions src/ingest/statistics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::RawEventKind;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

use super::RawEventKind;

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Statistics {
pub core: u32,
Expand Down
12 changes: 7 additions & 5 deletions src/ingest/sysmon.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::{
ingest::{convert_time_format, vec_to_string_or_default},
publish::range::ResponseRangeData,
};
use serde::{Deserialize, Serialize};
use std::{
fmt::{Display, Formatter},
net::IpAddr,
};

use serde::{Deserialize, Serialize};

use crate::{
ingest::{convert_time_format, vec_to_string_or_default},
publish::range::ResponseRangeData,
};

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct ProcessCreate {
pub agent_name: String,
Expand Down
6 changes: 4 additions & 2 deletions src/ingest/timeseries.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::publish::range::ResponseRangeData;
use std::fmt::{Display, Formatter};

use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

use crate::publish::range::ResponseRangeData;

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct PeriodicTimeSeries {
Expand Down
17 changes: 10 additions & 7 deletions src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
pub mod range;
pub mod stream;

use std::{mem, net::IpAddr};

use anyhow::Result;
use quinn::{Connection, ConnectionError, RecvStream, SendStream};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use thiserror::Error;

use self::{
range::{MessageCode, ResponseRangeData},
stream::{NodeType, RequestStreamRecord},
};
use crate::frame::{self, recv_bytes, recv_raw, send_bytes, send_raw, RecvError, SendError};
use anyhow::Result;
use quinn::{Connection, ConnectionError, RecvStream, SendStream};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{mem, net::IpAddr};
use thiserror::Error;

/// The error type for a publish failure.
#[allow(clippy::module_name_repetitions)]
Expand Down Expand Up @@ -448,12 +450,13 @@ pub async fn recv_ack_response(recv: &mut RecvStream) -> Result<(), PublishError

#[cfg(test)]
mod tests {
use std::net::IpAddr;
use std::str::FromStr;

use crate::frame;
use crate::ingest::network::Conn;
use crate::publish::{recv_ack_response, PublishError};
use crate::test::{channel, TOKEN};
use std::net::IpAddr;
use std::str::FromStr;

#[tokio::test]
async fn publish_send_recv() {
Expand Down
3 changes: 2 additions & 1 deletion src/publish/stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::net::IpAddr;

use anyhow::{anyhow, Result};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use serde::{Deserialize, Serialize};
use std::net::IpAddr;

pub const STREAM_REQUEST_ALL_SOURCE: &str = "all";

Expand Down
3 changes: 2 additions & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ lazy_static! {
/// Creates a bidirectional channel, returning server's send and receive and
/// client's send and receive streams.
pub(crate) async fn channel() -> Channel {
use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
use std::{
net::{IpAddr, Ipv6Addr, SocketAddr},
sync::Arc,
};

use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
const TEST_SERVER_NAME: &str = "test-server";
const TEST_PORT: u16 = 60190;

Expand Down

0 comments on commit 0cb180b

Please sign in to comment.