Skip to content

Commit

Permalink
Make impmod! look nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
kotauskas committed Mar 23, 2024
1 parent fea1987 commit be61d98
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/local_socket/listener/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use {crate::os::unix::uds_local_socket as uds_impl, std::os::unix::prelude::*};
#[cfg(windows)]
use {crate::os::windows::named_pipe::local_socket as np_impl, std::os::windows::prelude::*};

impmod! {local_socket::dispatch_sync,
self,
}
impmod! {local_socket::dispatch_sync}

mkenum!(
/// Local socket server, listening for connections.
Expand Down
4 changes: 1 addition & 3 deletions src/local_socket/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use std::{
fmt::Debug,
};

impmod! {local_socket::name,
is_namespaced,
}
impmod! {local_socket::name, is_namespaced}

// TODO maybe emulate NS on FS-only via tmpfs?
// TODO better PartialEq
Expand Down
5 changes: 1 addition & 4 deletions src/local_socket/stream/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use {crate::os::unix::uds_local_socket as uds_impl, std::os::unix::prelude::*};
#[cfg(windows)]
use {crate::os::windows::named_pipe::local_socket as np_impl, std::os::windows::prelude::*};

// FIXME awkward macro syntax
impmod! {local_socket::dispatch_sync,
self,
}
impmod! { local_socket::dispatch_sync }

macro_rules! dispatch_read {
(@iw $ty:ident) => {
Expand Down
8 changes: 3 additions & 5 deletions src/local_socket/tokio/listener/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use std::io;
#[cfg(unix)]
use {crate::os::unix::uds_local_socket::tokio as uds_impl, std::os::unix::prelude::*};

impmod! {local_socket::dispatch_tokio,
self,
}
impmod! { local_socket::dispatch_tokio as dispatch }

// TODO borrowed split in examples

Expand Down Expand Up @@ -112,11 +110,11 @@ impl r#trait::Listener for Listener {

#[inline]
fn bind(name: Name<'_>) -> io::Result<Self> {
dispatch_tokio::bind(name)
dispatch::bind(name)
}
#[inline]
fn bind_without_name_reclamation(name: Name<'_>) -> io::Result<Self> {
dispatch_tokio::bind_without_name_reclamation(name)
dispatch::bind_without_name_reclamation(name)
}
#[inline]
async fn accept(&self) -> io::Result<Stream> {

Check failure on line 120 in src/local_socket/tokio/listener/enum.rs

View workflow job for this annotation

GitHub Actions / 1.74.0 on ubuntu-latest

functions in traits cannot be declared `async`

Check failure on line 120 in src/local_socket/tokio/listener/enum.rs

View workflow job for this annotation

GitHub Actions / 1.74.0 on windows-latest

functions in traits cannot be declared `async`

Check failure on line 120 in src/local_socket/tokio/listener/enum.rs

View workflow job for this annotation

GitHub Actions / 1.74.0 on macos-latest

functions in traits cannot be declared `async`
Expand Down
4 changes: 1 addition & 3 deletions src/local_socket/tokio/stream/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use {
crate::os::windows::named_pipe::local_socket::tokio as np_impl, std::os::windows::prelude::*,
};

impmod! {local_socket::dispatch_tokio,
self as dispatch,
}
impmod! { local_socket::dispatch_tokio as dispatch }

macro_rules! dispatch_read {
(@iw $ty:ident) => {
Expand Down
6 changes: 5 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#![allow(unused_macros)]
// TODO more internal docs

macro_rules! impmod { // TODO remove
/// Dispatches to a symmetrically named submodule in the target OS module.
macro_rules! impmod {
($($osmod:ident)::+ $(as $into:ident)?) => {
impmod!($($osmod)::+, self $(as $into)?);
};
($($osmod:ident)::+, $($orig:ident $(as $into:ident)?),* $(,)?) => {
#[cfg(unix)]
use $crate::os::unix::$($osmod)::+::{$($orig $(as $into)?,)*};
Expand Down

0 comments on commit be61d98

Please sign in to comment.