From 5cc696a8b99ec7bd1b060200159326b26f7c35e0 Mon Sep 17 00:00:00 2001 From: Laurent Pelecq Date: Thu, 17 Mar 2022 21:30:08 +0100 Subject: [PATCH] Rename FifoBuilder to Builder Builder is not reexported in lib.rs. Module fifo must be imported instead. --- examples/hello.rs | 6 +++--- examples/list.rs | 4 ++-- examples/notifications.rs | 4 ++-- src/fifo.rs | 30 +++++++++++++++--------------- src/lib.rs | 10 +++++----- tests/fifo_async_tests.rs | 2 +- tests/fifo_sync_tests.rs | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/hello.rs b/examples/hello.rs index 25151e1..ec03016 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,4 +1,4 @@ -use ssip_client::{ClientName, ClientResult, FifoBuilder}; +use ssip_client::{fifo, ClientName, ClientResult}; // ============================== // Synchronous implementation @@ -6,7 +6,7 @@ use ssip_client::{ClientName, ClientResult, FifoBuilder}; #[cfg(not(feature = "async-mio"))] fn main() -> ClientResult<()> { - let mut client = FifoBuilder::new().build()?; + let mut client = fifo::Builder::new().build()?; client .set_client_name(ClientName::new("joe", "hello"))? .check_client_name_set()?; @@ -125,7 +125,7 @@ fn main() -> ClientResult<()> { // Create the poll object, the client and register the socket. let mut poll = Poll::new()?; let mut events = Events::with_capacity(16); - let mut client = FifoBuilder::new().build()?; + let mut client = fifo::Builder::new().build()?; let input_token = Token(0); let output_token = Token(1); client.register(&poll, input_token, output_token)?; diff --git a/examples/list.rs b/examples/list.rs index 9222720..9164acc 100644 --- a/examples/list.rs +++ b/examples/list.rs @@ -1,6 +1,6 @@ #[cfg(not(feature = "async-mio"))] use ssip_client::{ - ClientName, ClientResult, FifoBuilder, SynthesisVoice, OK_OUTPUT_MODULES_LIST_SENT, + fifo, ClientName, ClientResult, SynthesisVoice, OK_OUTPUT_MODULES_LIST_SENT, OK_VOICES_LIST_SENT, }; @@ -23,7 +23,7 @@ fn main() -> ClientResult<()> { } } - let mut client = FifoBuilder::new().build()?; + let mut client = fifo::Builder::new().build()?; client .set_client_name(ClientName::new("joe", "list"))? .check_client_name_set()?; diff --git a/examples/notifications.rs b/examples/notifications.rs index aee7068..e87b04a 100644 --- a/examples/notifications.rs +++ b/examples/notifications.rs @@ -1,11 +1,11 @@ #[cfg(not(feature = "async-mio"))] use ssip_client::{ - ClientName, ClientResult, EventType, FifoBuilder, NotificationType, OK_NOTIFICATION_SET, + fifo, ClientName, ClientResult, EventType, NotificationType, OK_NOTIFICATION_SET, }; #[cfg(not(feature = "async-mio"))] fn main() -> ClientResult<()> { - let mut client = FifoBuilder::new().build()?; + let mut client = fifo::Builder::new().build()?; client .set_client_name(ClientName::new("joe", "notifications"))? .check_client_name_set()?; diff --git a/src/fifo.rs b/src/fifo.rs index 4542ccf..308846f 100644 --- a/src/fifo.rs +++ b/src/fifo.rs @@ -61,20 +61,20 @@ mod synchronous { use super::FifoPath; - pub struct FifoBuilder { + pub struct Builder { path: FifoPath, read_timeout: Option, } - impl FifoBuilder { - pub fn new() -> FifoBuilder { - FifoBuilder { + impl Builder { + pub fn new() -> Self { + Self { path: FifoPath::new(), read_timeout: None, } } - pub fn path

(&mut self, socket_path: P) -> &mut FifoBuilder + pub fn path

(&mut self, socket_path: P) -> &mut Self where P: AsRef, { @@ -82,7 +82,7 @@ mod synchronous { self } - pub fn timeout(&mut self, read_timeout: Duration) -> &mut FifoBuilder { + pub fn timeout(&mut self, read_timeout: Duration) -> &mut Self { self.read_timeout = Some(read_timeout); self } @@ -97,7 +97,7 @@ mod synchronous { } #[cfg(not(feature = "async-mio"))] -pub use synchronous::{FifoBuilder, UnixStream}; +pub use synchronous::{Builder, UnixStream}; #[cfg(feature = "async-mio")] mod asynchronous { @@ -110,13 +110,13 @@ mod asynchronous { use super::FifoPath; - pub struct FifoBuilder { + pub struct Builder { path: FifoPath, } - impl FifoBuilder { + impl Builder { pub fn new() -> Self { - FifoBuilder { + Self { path: FifoPath::new(), } } @@ -126,7 +126,7 @@ mod asynchronous { Ok(socket) } - pub fn path

(&mut self, socket_path: P) -> &mut FifoBuilder + pub fn path

(&mut self, socket_path: P) -> &mut Self where P: AsRef, { @@ -137,19 +137,19 @@ mod asynchronous { pub fn build(&self) -> io::Result> { let stream = StdUnixStream::connect(self.path.get()?)?; Ok(Client::new( - BufReader::new(UnixStream::from_std(FifoBuilder::non_blocking( + BufReader::new(UnixStream::from_std(Self::non_blocking( stream.try_clone()?, )?)), - BufWriter::new(UnixStream::from_std(FifoBuilder::non_blocking(stream)?)), + BufWriter::new(UnixStream::from_std(Self::non_blocking(stream)?)), )) } } } #[cfg(feature = "async-mio")] -pub use asynchronous::{FifoBuilder, UnixStream}; +pub use asynchronous::{Builder, UnixStream}; -impl Default for FifoBuilder { +impl Default for Builder { fn default() -> Self { Self::new() } diff --git a/src/lib.rs b/src/lib.rs index 936d583..b8db7f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,8 +16,8 @@ //! //! Example //! ```no_run -//! use ssip_client::{FifoBuilder, ClientName}; -//! let mut client = FifoBuilder::new().build()?; +//! use ssip_client::{fifo, ClientName}; +//! let mut client = fifo::Builder::new().build()?; //! client //! .set_client_name(ClientName::new("joe", "hello"))? //! .check_client_name_set()?; @@ -30,12 +30,12 @@ mod protocol; mod client; -mod constants; -mod fifo; mod types; +pub mod constants; +pub mod fifo; + pub use client::{Client, ClientError, ClientName, ClientResult, ClientStatus}; pub use constants::*; -pub use fifo::FifoBuilder; pub use types::StatusLine; pub use types::*; diff --git a/tests/fifo_async_tests.rs b/tests/fifo_async_tests.rs index ec5a238..4b44e26 100644 --- a/tests/fifo_async_tests.rs +++ b/tests/fifo_async_tests.rs @@ -76,7 +76,7 @@ fn basic_async_communication() -> std::io::Result<()> { let handle = Server::run(&server_path, &COMMUNICATION); let mut poll = Poll::new()?; let mut events = Events::with_capacity(128); - let mut client = FifoBuilder::new().path(&server_path).build().unwrap(); + let mut client = fifo::Builder::new().path(&server_path).build().unwrap(); let input_token = Token(0); let output_token = Token(1); client.register(&poll, input_token, output_token).unwrap(); diff --git a/tests/fifo_sync_tests.rs b/tests/fifo_sync_tests.rs index 6b3fada..790db3c 100644 --- a/tests/fifo_sync_tests.rs +++ b/tests/fifo_sync_tests.rs @@ -34,7 +34,7 @@ where let mut process_wrapper = std::panic::AssertUnwindSafe(process); let result = std::panic::catch_unwind(move || { let handle = Server::run(&server_path, communication); - let mut client = ssip_client::FifoBuilder::new() + let mut client = ssip_client::fifo::Builder::new() .path(&server_path) .build() .unwrap();