Repository: lldap/lldap (language: rust)

Issue:
[BUG] Error building on Windows
**Describe the bug**
Doing a `cargo build` on Windows 10 x64 running Rust 1.79 x86_64-pc-windows-msvc returns an error:

```
   Compiling lldap v0.5.1-alpha (C:\Users\EAnderson\Downloads\lldap\lldap-main\server)
error[E0433]: failed to resolve: could not find `unix` in `os`
   --> server\src\infra\configuration.rs:239:22
    |
239 |         use std::os::unix::fs::PermissionsExt;
    |                      ^^^^ could not find `unix` in `os`
    |
note: found an item that was configured out
   --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\std\src\os\mod.rs:26:9
note: found an item that was configured out
   --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\std\src\os\mod.rs:64:9

error[E0599]: no method named `set_mode` found for struct `Permissions` in the current scope
   --> server\src\infra\configuration.rs:240:21
    |
240 |         permissions.set_mode(0o400);
    |                     ^^^^^^^^ method not found in `Permissions`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `lldap` (bin "lldap") due to 2 previous errors
```

**To Reproduce**
Execute `cargo build` on Windows

**Expected behavior**
The build to succeed.

**Workaround**
Commented-out lines 239 - 242 of configration.rs.



Discussion / hints:
Well met from HN ;)
Ah, I thought that `if cfg!` would do the right thing, but no, we need a conditional compilation, something like 

```rust
#[cfg(unix)]
{
  ...
}
```

Do you think you can make a PR for that?

Fix patch:
diff --git a/server/src/infra/configuration.rs b/server/src/infra/configuration.rs
index 733c86e8..e99763e5 100644
--- a/server/src/infra/configuration.rs
+++ b/server/src/infra/configuration.rs
@@ -229,16 +229,22 @@ fn generate_random_private_key() -> ServerSetup {
     ServerSetup::new(&mut rng)
 }
 
+#[cfg(unix)]
+fn set_mode(permissions: &mut std::fs::Permissions) {
+    use std::os::unix::fs::PermissionsExt;
+    permissions.set_mode(0o400);
+}
+
+#[cfg(not(unix))]
+fn set_mode(_: &mut std::fs::Permissions) {}
+
 fn write_to_readonly_file(path: &std::path::Path, buffer: &[u8]) -> Result<()> {
     use std::{fs::File, io::Write};
     assert!(!path.exists());
     let mut file = File::create(path)?;
     let mut permissions = file.metadata()?.permissions();
     permissions.set_readonly(true);
-    if cfg!(unix) {
-        use std::os::unix::fs::PermissionsExt;
-        permissions.set_mode(0o400);
-    }
+    set_mode(&mut permissions);
     file.set_permissions(permissions)?;
     Ok(file.write_all(buffer)?)
 }


Test patch: