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

Prepare support for windows #60

Merged
merged 6 commits into from
Mar 11, 2022
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: 2 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ impl SessionBuilder {
/// be created.
///
/// If not set, `./` will be used (the current directory).
#[cfg(not(windows))]
#[cfg_attr(docsrs, doc(cfg(not(windows))))]
pub fn control_directory(&mut self, p: impl AsRef<Path>) -> &mut Self {
self.control_dir = Some(p.as_ref().to_path_buf());
self
Expand Down
4 changes: 4 additions & 0 deletions src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use crate::*;

/// TODO: RENAME THIS INTO THE NEXT VERSION BEFORE RELEASE
#[doc(hidden)]
/// ## Changed
/// - Make [`Session::check`] available only on unix.
/// - Make [`Socket::UnixSocket`] available only on unix.
/// - Make [`SessionBuilder::control_directory`] available only on unix.
pub mod unreleased {}

/// ## Fixed
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ impl Session {
}

/// Check the status of the underlying SSH connection.
#[cfg(not(windows))]
#[cfg_attr(docsrs, doc(cfg(not(windows))))]
pub async fn check(&self) -> Result<(), Error> {
delegate!(&self.0, imp, { imp.check().await })
}
Expand Down
5 changes: 5 additions & 0 deletions src/port_forwarding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ impl From<ForwardType> for native_mux_impl::ForwardType {
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum Socket<'a> {
/// Unix socket.
#[cfg(unix)]
#[cfg_attr(docsrs, doc(cfg(unix)))]
UnixSocket {
/// Filesystem path
path: Cow<'a, Path>,
Expand All @@ -59,6 +61,7 @@ impl Socket<'_> {
#[cfg(feature = "process-mux")]
pub(crate) fn as_os_str(&self) -> Cow<'_, OsStr> {
match self {
#[cfg(unix)]
Socket::UnixSocket { path } => Cow::Borrowed(path.as_os_str()),
Socket::TcpSocket(socket) => Cow::Owned(format!("{}", socket).into()),
}
Expand All @@ -71,6 +74,7 @@ impl<'a> From<Socket<'a>> for native_mux_impl::Socket<'a> {
use native_mux_impl::Socket::*;

match socket {
#[cfg(unix)]
Socket::UnixSocket { path } => UnixSocket { path },
Socket::TcpSocket(socket) => TcpSocket {
port: socket.port() as u32,
Expand All @@ -83,6 +87,7 @@ impl<'a> From<Socket<'a>> for native_mux_impl::Socket<'a> {
impl<'a> fmt::Display for Socket<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
#[cfg(unix)]
Socket::UnixSocket { path } => {
write!(f, "{}", path.to_string_lossy())
}
Expand Down