Skip to content

Commit 2ac15ce

Browse files
committed
feat: v2.0.9
1 parent 81c034f commit 2ac15ce

File tree

19 files changed

+75
-99
lines changed

19 files changed

+75
-99
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "udp"
3-
version = "2.0.8"
3+
version = "2.0.9"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]

src/common/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub(crate) mod r#const;
22
pub(crate) mod r#type;
33

4-
pub use r#const::*;
5-
pub use r#type::*;
4+
pub use {r#const::*, r#type::*};

src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ pub(crate) mod r#struct;
44
pub(crate) mod r#type;
55

66
pub use r#const::*;
7-
pub(crate) use r#struct::*;
8-
pub(crate) use r#type::*;
7+
8+
pub(crate) use {r#struct::*, r#type::*};

src/context/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ pub(crate) mod r#impl;
22
pub(crate) mod r#struct;
33
pub(crate) mod r#type;
44

5-
pub use r#struct::*;
6-
pub use r#type::*;
5+
pub use {r#struct::*, r#type::*};

src/handler/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ pub(crate) mod r#impl;
33
pub(crate) mod r#trait;
44
pub(crate) mod r#type;
55

6-
pub(crate) use r#fn::*;
7-
pub(crate) use r#trait::*;
8-
pub(crate) use r#type::*;
6+
pub(crate) use {r#fn::*, r#trait::*, r#type::*};

src/lib.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,23 @@
33
//! A lightweight and efficient Rust library for
44
//! building UDP servers with request-response handling.
55
6-
pub(crate) mod cfg;
7-
pub(crate) mod common;
8-
pub(crate) mod config;
9-
pub(crate) mod context;
10-
pub(crate) mod handler;
11-
pub(crate) mod request;
12-
pub(crate) mod response;
13-
pub(crate) mod server;
14-
pub(crate) mod socket;
15-
pub(crate) mod utils;
6+
mod common;
7+
mod config;
8+
mod context;
9+
mod handler;
10+
mod request;
11+
mod response;
12+
mod server;
13+
mod socket;
14+
mod utils;
1615

17-
pub use config::*;
18-
pub use context::*;
19-
pub use request::*;
20-
pub use response::*;
21-
pub use server::*;
22-
pub use socket::*;
23-
pub use utils::*;
16+
pub use {config::*, context::*, request::*, response::*, server::*, socket::*, utils::*};
2417

2518
pub use tokio;
2619

27-
pub(crate) use common::*;
28-
pub(crate) use handler::*;
20+
use {common::*, handler::*};
2921

30-
pub(crate) use std::{
22+
use std::{
3123
any::Any,
3224
collections::HashMap,
3325
error::Error as StdError,
@@ -38,7 +30,8 @@ pub(crate) use std::{
3830
pin::Pin,
3931
sync::Arc,
4032
};
41-
pub(crate) use tokio::{
33+
34+
use tokio::{
4235
net::UdpSocket,
4336
sync::{MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard},
4437
};

src/response/error/impl.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/response/error/mod.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/response/impl.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
use crate::*;
22

3+
/// Standard error implementation for ResponseError.
4+
impl StdError for ResponseError {}
5+
6+
/// Display implementation for ResponseError.
7+
impl Display for ResponseError {
8+
/// Formats the error for display.
9+
///
10+
/// # Arguments
11+
///
12+
/// - `&fmt::Formatter` - Formatter for the output.
13+
///
14+
/// # Returns
15+
///
16+
/// - `fmt::Result` - Result of formatting operation.
17+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18+
match self {
19+
Self::ResponseError(data) => write!(f, "Response Error{COLON_SPACE}{data}"),
20+
Self::Unknown => write!(f, "Unknown"),
21+
}
22+
}
23+
}
24+
325
/// Default implementation for Response.
426
impl Default for Response {
527
/// Creates a default empty response.
@@ -62,10 +84,10 @@ impl Response {
6284
socket
6385
.send_to(response_data, &addr)
6486
.await
65-
.map_err(|e| response::error::ResponseError::ResponseError(e.to_string()))?;
87+
.map_err(|e| ResponseError::ResponseError(e.to_string()))?;
6688
return Ok(());
6789
}
6890
}
69-
Err(response::error::ResponseError::Unknown)
91+
Err(ResponseError::Unknown)
7092
}
7193
}

0 commit comments

Comments
 (0)