Rename FifoBuilder to Builder

Builder is not reexported in lib.rs. Module fifo must be imported instead.
main
Laurent Pelecq 2 years ago
parent b3dd02603a
commit 5cc696a8b9

@ -1,4 +1,4 @@
use ssip_client::{ClientName, ClientResult, FifoBuilder}; use ssip_client::{fifo, ClientName, ClientResult};
// ============================== // ==============================
// Synchronous implementation // Synchronous implementation
@ -6,7 +6,7 @@ use ssip_client::{ClientName, ClientResult, FifoBuilder};
#[cfg(not(feature = "async-mio"))] #[cfg(not(feature = "async-mio"))]
fn main() -> ClientResult<()> { fn main() -> ClientResult<()> {
let mut client = FifoBuilder::new().build()?; let mut client = fifo::Builder::new().build()?;
client client
.set_client_name(ClientName::new("joe", "hello"))? .set_client_name(ClientName::new("joe", "hello"))?
.check_client_name_set()?; .check_client_name_set()?;
@ -125,7 +125,7 @@ fn main() -> ClientResult<()> {
// Create the poll object, the client and register the socket. // Create the poll object, the client and register the socket.
let mut poll = Poll::new()?; let mut poll = Poll::new()?;
let mut events = Events::with_capacity(16); 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 input_token = Token(0);
let output_token = Token(1); let output_token = Token(1);
client.register(&poll, input_token, output_token)?; client.register(&poll, input_token, output_token)?;

@ -1,6 +1,6 @@
#[cfg(not(feature = "async-mio"))] #[cfg(not(feature = "async-mio"))]
use ssip_client::{ 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, 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 client
.set_client_name(ClientName::new("joe", "list"))? .set_client_name(ClientName::new("joe", "list"))?
.check_client_name_set()?; .check_client_name_set()?;

@ -1,11 +1,11 @@
#[cfg(not(feature = "async-mio"))] #[cfg(not(feature = "async-mio"))]
use ssip_client::{ use ssip_client::{
ClientName, ClientResult, EventType, FifoBuilder, NotificationType, OK_NOTIFICATION_SET, fifo, ClientName, ClientResult, EventType, NotificationType, OK_NOTIFICATION_SET,
}; };
#[cfg(not(feature = "async-mio"))] #[cfg(not(feature = "async-mio"))]
fn main() -> ClientResult<()> { fn main() -> ClientResult<()> {
let mut client = FifoBuilder::new().build()?; let mut client = fifo::Builder::new().build()?;
client client
.set_client_name(ClientName::new("joe", "notifications"))? .set_client_name(ClientName::new("joe", "notifications"))?
.check_client_name_set()?; .check_client_name_set()?;

@ -61,20 +61,20 @@ mod synchronous {
use super::FifoPath; use super::FifoPath;
pub struct FifoBuilder { pub struct Builder {
path: FifoPath, path: FifoPath,
read_timeout: Option<Duration>, read_timeout: Option<Duration>,
} }
impl FifoBuilder { impl Builder {
pub fn new() -> FifoBuilder { pub fn new() -> Self {
FifoBuilder { Self {
path: FifoPath::new(), path: FifoPath::new(),
read_timeout: None, read_timeout: None,
} }
} }
pub fn path<P>(&mut self, socket_path: P) -> &mut FifoBuilder pub fn path<P>(&mut self, socket_path: P) -> &mut Self
where where
P: AsRef<Path>, P: AsRef<Path>,
{ {
@ -82,7 +82,7 @@ mod synchronous {
self 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.read_timeout = Some(read_timeout);
self self
} }
@ -97,7 +97,7 @@ mod synchronous {
} }
#[cfg(not(feature = "async-mio"))] #[cfg(not(feature = "async-mio"))]
pub use synchronous::{FifoBuilder, UnixStream}; pub use synchronous::{Builder, UnixStream};
#[cfg(feature = "async-mio")] #[cfg(feature = "async-mio")]
mod asynchronous { mod asynchronous {
@ -110,13 +110,13 @@ mod asynchronous {
use super::FifoPath; use super::FifoPath;
pub struct FifoBuilder { pub struct Builder {
path: FifoPath, path: FifoPath,
} }
impl FifoBuilder { impl Builder {
pub fn new() -> Self { pub fn new() -> Self {
FifoBuilder { Self {
path: FifoPath::new(), path: FifoPath::new(),
} }
} }
@ -126,7 +126,7 @@ mod asynchronous {
Ok(socket) Ok(socket)
} }
pub fn path<P>(&mut self, socket_path: P) -> &mut FifoBuilder pub fn path<P>(&mut self, socket_path: P) -> &mut Self
where where
P: AsRef<Path>, P: AsRef<Path>,
{ {
@ -137,19 +137,19 @@ mod asynchronous {
pub fn build(&self) -> io::Result<Client<UnixStream>> { pub fn build(&self) -> io::Result<Client<UnixStream>> {
let stream = StdUnixStream::connect(self.path.get()?)?; let stream = StdUnixStream::connect(self.path.get()?)?;
Ok(Client::new( Ok(Client::new(
BufReader::new(UnixStream::from_std(FifoBuilder::non_blocking( BufReader::new(UnixStream::from_std(Self::non_blocking(
stream.try_clone()?, 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")] #[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 { fn default() -> Self {
Self::new() Self::new()
} }

@ -16,8 +16,8 @@
//! //!
//! Example //! Example
//! ```no_run //! ```no_run
//! use ssip_client::{FifoBuilder, ClientName}; //! use ssip_client::{fifo, ClientName};
//! let mut client = FifoBuilder::new().build()?; //! let mut client = fifo::Builder::new().build()?;
//! client //! client
//! .set_client_name(ClientName::new("joe", "hello"))? //! .set_client_name(ClientName::new("joe", "hello"))?
//! .check_client_name_set()?; //! .check_client_name_set()?;
@ -30,12 +30,12 @@
mod protocol; mod protocol;
mod client; mod client;
mod constants;
mod fifo;
mod types; mod types;
pub mod constants;
pub mod fifo;
pub use client::{Client, ClientError, ClientName, ClientResult, ClientStatus}; pub use client::{Client, ClientError, ClientName, ClientResult, ClientStatus};
pub use constants::*; pub use constants::*;
pub use fifo::FifoBuilder;
pub use types::StatusLine; pub use types::StatusLine;
pub use types::*; pub use types::*;

@ -76,7 +76,7 @@ fn basic_async_communication() -> std::io::Result<()> {
let handle = Server::run(&server_path, &COMMUNICATION); let handle = Server::run(&server_path, &COMMUNICATION);
let mut poll = Poll::new()?; let mut poll = Poll::new()?;
let mut events = Events::with_capacity(128); 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 input_token = Token(0);
let output_token = Token(1); let output_token = Token(1);
client.register(&poll, input_token, output_token).unwrap(); client.register(&poll, input_token, output_token).unwrap();

@ -34,7 +34,7 @@ where
let mut process_wrapper = std::panic::AssertUnwindSafe(process); let mut process_wrapper = std::panic::AssertUnwindSafe(process);
let result = std::panic::catch_unwind(move || { let result = std::panic::catch_unwind(move || {
let handle = Server::run(&server_path, communication); 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) .path(&server_path)
.build() .build()
.unwrap(); .unwrap();

Loading…
Cancel
Save