From 0119006052f96883536de739590b3fb2f79d085f Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Sun, 16 Jan 2022 13:28:55 -0800 Subject: [PATCH] refactor: Rename methods from `into_` to `to_` --- src/action.rs | 8 ++++---- src/condition.rs | 10 +++++----- src/event.rs | 10 +++++----- src/identifier.rs | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/action.rs b/src/action.rs index d8edbe4..82393bc 100644 --- a/src/action.rs +++ b/src/action.rs @@ -57,13 +57,13 @@ impl Action { let maybe_connection = match connection_identifier { Some(connection_identifier) => { - connection_identifier.into_connection(conn).await + connection_identifier.to_connection(conn).await } None => Ok(None), }?; let maybe_device = match device_identifier { - Some(device_identifier) => device_identifier.into_device(conn).await?, + Some(device_identifier) => device_identifier.to_device(conn).await?, None => None, }; @@ -92,7 +92,7 @@ impl Action { ); match active_connection_identifier - .into_active_connection(conn) + .to_active_connection(conn) .await? { Some(active_connection) => { @@ -118,7 +118,7 @@ impl Action { ); let output = Command::new(program) - .args(arguments.into_iter()) + .args(arguments.iter()) .output() .await?; diff --git a/src/condition.rs b/src/condition.rs index 810e1d2..a523683 100644 --- a/src/condition.rs +++ b/src/condition.rs @@ -81,7 +81,7 @@ impl Condition { } => { log::debug!("Evaluating DeviceIsConnected condition for {:?}", device_id); - match device_id.into_device(conn).await? { + match device_id.to_device(conn).await? { Some(device) => { device_matches_states( &device, @@ -100,7 +100,7 @@ impl Condition { device_id ); - match device_id.into_device(conn).await? { + match device_id.to_device(conn).await? { Some(device) => { device_matches_states( &device, @@ -122,7 +122,7 @@ impl Condition { device_id ); - match device_id.into_device(conn).await? { + match device_id.to_device(conn).await? { Some(device) => device_matches_states(&device, states.clone()).await, None => Ok(false), } @@ -175,11 +175,11 @@ async fn device_is_connected_to_one_of( device_identifier: &DeviceIdentifier, connections: &[ActiveConnectionIdentifier], ) -> Result<bool> { - match device_identifier.into_device(conn).await? { + match device_identifier.to_device(conn).await? { Some(device) => { let active_connections: Vec<ActiveConnectionWrapper> = stream::iter(connections) .filter_map(|connection_identifier| async move { - match connection_identifier.into_active_connection(conn).await { + match connection_identifier.to_active_connection(conn).await { Ok(active_connection) => active_connection, Err(err) => { log::error!( diff --git a/src/event.rs b/src/event.rs index 87fec3a..073ceb6 100644 --- a/src/event.rs +++ b/src/event.rs @@ -117,7 +117,7 @@ impl Trigger { (Event::DeviceAdded { device_path }, Trigger::DeviceAdded { device_identifier }) => { match device_identifier { Some(device_identified) => { - let trigger_device_path = device_identified.into_path(conn).await?; + let trigger_device_path = device_identified.to_path(conn).await?; Ok(device_path.eq(&trigger_device_path)) } @@ -129,7 +129,7 @@ impl Trigger { Trigger::DeviceRemoved { device_identifier }, ) => match device_identifier { Some(device_identified) => { - let trigger_device_path = device_identified.into_path(conn).await?; + let trigger_device_path = device_identified.to_path(conn).await?; Ok(device_path.eq(&trigger_device_path)) } @@ -140,7 +140,7 @@ impl Trigger { Trigger::DeviceActivated { device_identifier }, ) => match device_identifier { Some(device_identified) => { - let trigger_device_path = device_identified.into_path(conn).await?; + let trigger_device_path = device_identified.to_path(conn).await?; Ok(device_path.eq(&trigger_device_path)) } @@ -151,7 +151,7 @@ impl Trigger { Trigger::DeviceDeactivating { device_identifier }, ) => match device_identifier { Some(device_identified) => { - let trigger_device_path = device_identified.into_path(conn).await?; + let trigger_device_path = device_identified.to_path(conn).await?; Ok(device_path.eq(&trigger_device_path)) } @@ -162,7 +162,7 @@ impl Trigger { Trigger::DeviceDisconnected { device_identifier }, ) => match device_identifier { Some(device_identified) => { - let trigger_device_path = device_identified.into_path(conn).await?; + let trigger_device_path = device_identified.to_path(conn).await?; Ok(device_path.eq(&trigger_device_path)) } diff --git a/src/identifier.rs b/src/identifier.rs index 4839ac9..b85d945 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -17,7 +17,7 @@ pub enum DeviceIdentifier { } impl DeviceIdentifier { - pub async fn into_path(&self, conn: &Arc<SyncConnection>) -> Result<Path<'static>> { + pub async fn to_path(&self, conn: &Arc<SyncConnection>) -> Result<Path<'static>> { match self { DeviceIdentifier::DeviceInterface { device_interface } => { let manager = ManagerWrapper::from_connection(conn).await; @@ -33,11 +33,11 @@ impl DeviceIdentifier { } } - pub async fn into_device( + pub async fn to_device( &self, conn: &Arc<SyncConnection>, ) -> Result<Option<DeviceWrapper<'static>>> { - match self.into_path(conn).await { + match self.to_path(conn).await { Ok(device_path) => { let device = DeviceWrapper::from_path(conn.clone(), device_path).await; @@ -60,7 +60,7 @@ pub enum ConnectionIdentifier { } impl ConnectionIdentifier { - pub async fn into_connection<'a>( + pub async fn to_connection<'a>( &'a self, conn: &Arc<SyncConnection>, ) -> Result<Option<ConnectionWrapper<'a>>> { @@ -91,7 +91,7 @@ pub enum ActiveConnectionIdentifier { } impl ActiveConnectionIdentifier { - pub async fn into_active_connection<'a>( + pub async fn to_active_connection<'a>( &'a self, conn: &Arc<SyncConnection>, ) -> Result<Option<ActiveConnectionWrapper<'a>>> { -- GitLab