Cleanup & reformat
This commit is contained in:
@@ -23,12 +23,6 @@
|
|||||||
//! Primary entrypoint is [`SmbClient`](struct.SmbClient.html) struct.
|
//! Primary entrypoint is [`SmbClient`](struct.SmbClient.html) struct.
|
||||||
//!
|
//!
|
||||||
//! Files are represented by [`SmbFile`](struct.SmbFile.html).
|
//! Files are represented by [`SmbFile`](struct.SmbFile.html).
|
||||||
//!
|
|
||||||
//! Basic example:
|
|
||||||
//! ```rust
|
|
||||||
//! fn load
|
|
||||||
//! # fn main() {}
|
|
||||||
//! ```
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|||||||
14
src/smbc.rs
14
src/smbc.rs
@@ -70,7 +70,7 @@ const SMBC_TRUE: smbc_bool = 1;
|
|||||||
/// let auth = move |host: &str, share: &str| {
|
/// let auth = move |host: &str, share: &str| {
|
||||||
/// (Cow::Borrowed("WORKGROUP"), Cow::Borrowed("test"), Cow::Borrowed(password_ref))
|
/// (Cow::Borrowed("WORKGROUP"), Cow::Borrowed("test"), Cow::Borrowed(password_ref))
|
||||||
/// };
|
/// };
|
||||||
/// let client = try!(smbc::SmbClient::new(&auth));
|
/// let client = smbc::SmbClient::new(&auth)?;
|
||||||
///
|
///
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
@@ -103,7 +103,7 @@ pub struct SmbClient<'a> {
|
|||||||
/// #
|
/// #
|
||||||
/// fn get_content(file: &mut smbc::SmbFile) -> smbc::Result<String> {
|
/// fn get_content(file: &mut smbc::SmbFile) -> smbc::Result<String> {
|
||||||
/// let mut buffer = String::new();
|
/// let mut buffer = String::new();
|
||||||
/// try!(file.read_to_string(&mut buffer));
|
/// file.read_to_string(&mut buffer)?;
|
||||||
/// Ok(buffer)
|
/// Ok(buffer)
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
@@ -113,8 +113,8 @@ pub struct SmbClient<'a> {
|
|||||||
/// # let auth = move |host: &str, share: &str| {
|
/// # let auth = move |host: &str, share: &str| {
|
||||||
/// # (Cow::Borrowed("WORKGROUP"), Cow::Borrowed("test"), Cow::Borrowed(password))
|
/// # (Cow::Borrowed("WORKGROUP"), Cow::Borrowed("test"), Cow::Borrowed(password))
|
||||||
/// # };
|
/// # };
|
||||||
/// let client = try!(smbc::SmbClient::new(&auth));
|
/// let client = smbc::SmbClient::new(&auth)?;
|
||||||
/// let mut file = try!(client.open("smb://127.0.0.1/share/path/to/file"));
|
/// let mut file = client.open("smb://127.0.0.1/share/path/to/file")?;
|
||||||
/// println!("dumped file:\n\n{}", try!(get_content(&mut file)));
|
/// println!("dumped file:\n\n{}", try!(get_content(&mut file)));
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
@@ -144,7 +144,7 @@ impl<'a> SmbClient<'a> {
|
|||||||
where F: for<'b> Fn(&'b str, &'b str) -> (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>) {
|
where F: for<'b> Fn(&'b str, &'b str) -> (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>) {
|
||||||
let mut smbc = SmbClient {
|
let mut smbc = SmbClient {
|
||||||
ctx: ptr::null_mut(),
|
ctx: ptr::null_mut(),
|
||||||
auth_fn: auth_fn,
|
auth_fn,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -209,7 +209,7 @@ impl<'a> SmbClient<'a> {
|
|||||||
let open_fn = try_ufn!(smbc_getFunctionOpen <- self);
|
let open_fn = try_ufn!(smbc_getFunctionOpen <- self);
|
||||||
|
|
||||||
let path = cstring(path)?;
|
let path = cstring(path)?;
|
||||||
trace!(target: "smbc", "opening {:?} with {:?}", path, open_fn);
|
trace!(target: "smbc", "opening {:?}", path);
|
||||||
|
|
||||||
let fd = result_from_ptr_mut(open_fn(self.ctx,
|
let fd = result_from_ptr_mut(open_fn(self.ctx,
|
||||||
path.as_ptr(),
|
path.as_ptr(),
|
||||||
@@ -220,7 +220,7 @@ impl<'a> SmbClient<'a> {
|
|||||||
}
|
}
|
||||||
Ok(SmbFile {
|
Ok(SmbFile {
|
||||||
smbc: &self,
|
smbc: &self,
|
||||||
fd: fd,
|
fd,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user