Extend libdm_rust to build dm-crypt device

Add crypt module which supports building DmCryptTarget based dm table
entry. Also expose this via create_crypt_device()

Also, add unit test that use loopdevice as the backing device.

Test: atest libdm_rust.test
Bug: 250880499
Change-Id: Ibf09ca267cbcc7a2dc00dd835f2d8b781040f130
diff --git a/libs/devicemapper/src/util.rs b/libs/devicemapper/src/util.rs
index 913f827..e8df424 100644
--- a/libs/devicemapper/src/util.rs
+++ b/libs/devicemapper/src/util.rs
@@ -37,6 +37,21 @@
     Ok(())
 }
 
+/// Wait for the path to disappear
+#[cfg(test)]
+pub fn wait_for_path_disappears<P: AsRef<Path>>(path: P) -> Result<()> {
+    const TIMEOUT: Duration = Duration::from_secs(1);
+    const INTERVAL: Duration = Duration::from_millis(10);
+    let begin = Instant::now();
+    while !path.as_ref().exists() {
+        if begin.elapsed() > TIMEOUT {
+            bail!("{:?} not disappearing. TIMEOUT.", path.as_ref());
+        }
+        thread::sleep(INTERVAL);
+    }
+    Ok(())
+}
+
 /// Returns hexadecimal reprentation of a given byte array.
 pub fn hexstring_from(s: &[u8]) -> String {
     s.iter().map(|byte| format!("{:02x}", byte)).reduce(|i, j| i + &j).unwrap_or_default()