Giter Club home page Giter Club logo

sambrs's Introduction

Sambrs

A tiny ergonomic wrapper around WNetAddConnection2A and WNetCancelConnection2A. The goal is to offer an easy to use interface to connect to SMB network shares on Windows.

Sam -> SMB -> Rust -> Samba is taken!? -> sambrs

Features

  • Simple and ergonomic interface to connect to SMB network shares.
  • Support for specifying a local Windows mount point.
  • Options to persist connections across user login sessions.
  • Interactive mode for password prompts.

Installation

Add this to your Cargo.toml:

[dependencies]
sambrs = "0.1"

Usage

Instantiate an SmbShare with an optional local Windows mount point and establish a connection.

When calling the connect method, you have the option to persist the connection across user login sessions and to enable interactive mode. Interactive mode will block until the user either provides a correct password or cancels, resulting in a Canceled error.

use sambrs::SmbShare;

fn main() {
    let share = SmbShare::new(r"\\server\share", "user", "pass", Some('D'));

    match share.connect(false, false) {
        Ok(()) => println!("Connected successfully!"),
        Err(e) => eprintln!("Failed to connect: {}", e),
    }

    // use std::fs as if D:\ was a local directory
    dbg!(std::fs::metadata(r"D:\").unwrap().is_dir());
}

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Special Thanks

Special thanks to Christian Visintin for his informative blog post on accessing SMB shares with Rust on Windows. If you need a fully-featured remote file access solution that works across multiple protocols, you should definitely check out his project remotefs.

sambrs's People

Contributors

samvdst avatar

Stargazers

Kroucher avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.