Skip to content

Commit

Permalink
Adds a couple extra doc block examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaffin committed Apr 2, 2021
1 parent 0389b26 commit 15b271f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl LoopDevice {
///
/// ```rust
/// use loopdev::LoopDevice;
/// let ld = LoopDevice::open("/dev/loop7").unwrap();
/// let ld = LoopDevice::open("/dev/loop4").unwrap();
/// # ld.attach_file("test.img").unwrap();
/// ld.detach().unwrap();
/// ```
Expand All @@ -271,6 +271,33 @@ impl LoopDevice {
}

/// Used to set options when attaching a device. Created with [LoopDevice::with()].
///
/// # Examples
///
/// Enable partition scanning on attach:
///
/// ```rust
/// use loopdev::LoopDevice;
/// let mut ld = LoopDevice::open("/dev/loop4").unwrap();
/// ld.with()
/// .part_scan(true)
/// .attach("test.img")
/// .unwrap();
/// # ld.detach().unwrap();
/// ```
///
/// A 1MiB slice of the file located at 1KiB into the file.
///
/// ```rust
/// use loopdev::LoopDevice;
/// let mut ld = LoopDevice::open("/dev/loop4").unwrap();
/// ld.with()
/// .offset(1024*1024)
/// .size_limit(1024*1024*1024)
/// .attach("test.img")
/// .unwrap();
/// # ld.detach().unwrap();
/// ```
pub struct AttachOptions<'d> {
device: &'d mut LoopDevice,
info: LoopInfo64,
Expand Down

0 comments on commit 15b271f

Please sign in to comment.