Skip to content

Commit cdccd15

Browse files
committed
add with_config to Client
1 parent 2c004fd commit cdccd15

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lazuli_core/src/client/client.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use log::trace;
99

1010
use crate::{hash_type_id, stream::Stream, ArcMutex, Result, Sendable};
1111

12-
use super::{connector::StreamConnector, input, listener::SocketListener, StreamCollection};
12+
use super::{
13+
config::SocketConfig, connector::StreamConnector, input, listener::SocketListener,
14+
StreamCollection,
15+
};
1316
/// A client for sending and receiving data.
1417
pub struct Client {
1518
socket: ArcMutex<TcpStream>,
@@ -55,6 +58,12 @@ impl Client {
5558
))
5659
}
5760

61+
/// Applies the configuration to the socket.
62+
pub fn with_config(self, config: &SocketConfig) -> Result<Self> {
63+
config.apply_stream(&mut self.socket.lock().unwrap())?;
64+
Ok(self)
65+
}
66+
5867
/// Sends data to the socket.
5968
#[inline]
6069
pub fn send<T>(&mut self, data: &T) -> Result<()>

0 commit comments

Comments
 (0)