Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor low level clients #20

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["development-tools"]
edition = "2018"

[dependencies]
parsec-interface = "0.11.0"
parsec-interface = "0.13.0"
num = "0.2.1"
rand = "0.7.3"
log = "0.4.8"
Expand Down
495 changes: 495 additions & 0 deletions src/core/basic_client.rs

Large diffs are not rendered by default.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use std::time::Duration;
const DEFAULT_SOCKET_PATH: &str = "/tmp/security-daemon-socket";
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(1);

/// IPC client for Unix domain sockets
/// IPC handler for Unix domain sockets
#[derive(Debug, Clone)]
pub struct Client {
pub struct Handler {
/// Path at which the socket can be found
path: PathBuf,
/// Timeout for reads and writes on the streams
timeout: Option<Duration>,
}

impl Connect for Client {
impl Connect for Handler {
fn connect(&self) -> Result<Box<dyn ReadWrite>> {
let stream = UnixStream::connect(self.path.clone()).map_err(ClientErrorKind::Ipc)?;

Expand All @@ -34,16 +34,16 @@ impl Connect for Client {
}
}

impl Client {
impl Handler {
/// Create new client using given socket path and timeout duration
pub fn new(path: PathBuf, timeout: Option<Duration>) -> Self {
Client { path, timeout }
Handler { path, timeout }
}
}

impl Default for Client {
impl Default for Handler {
fn default() -> Self {
Client {
Handler {
path: DEFAULT_SOCKET_PATH.into(),
timeout: Some(DEFAULT_TIMEOUT),
}
Expand Down
Loading