]> git.proxmox.com Git - proxmox-backup.git/commitdiff
pbs-tools: drop borrow module
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 13 Oct 2021 08:40:50 +0000 (10:40 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 13 Oct 2021 12:14:03 +0000 (14:14 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
pbs-datastore/Cargo.toml
pbs-datastore/src/checksum_reader.rs
pbs-datastore/src/checksum_writer.rs
pbs-tools/Cargo.toml
pbs-tools/src/borrow.rs [deleted file]
pbs-tools/src/fs.rs
pbs-tools/src/lib.rs

index 8d53e995ac24fa9c45b189f0032de1a733b22b75..aae58260dcfef5473b3d2b0174d13f03f7b34214 100644 (file)
@@ -26,6 +26,7 @@ pathpatterns = "0.1.2"
 pxar = "0.10.1"
 
 proxmox = "0.14.0"
+proxmox-borrow = "1"
 proxmox-io = "1"
 proxmox-lang = "1"
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
index 7bf8f34d0d67d42187a7bce99074c0dae7e4a6c4..a1a508bd6b6a5e1955c3a00867bb8d8cf6df26fe 100644 (file)
@@ -2,7 +2,8 @@ use anyhow::{Error};
 use std::sync::Arc;
 use std::io::Read;
 
-use pbs_tools::borrow::Tied;
+use proxmox_borrow::Tied;
+
 use pbs_tools::crypt_config::CryptConfig;
 
 pub struct ChecksumReader<R> {
index 3c502dddd6f5456fffb233bbac212b44d2fc15bf..ea9e1b9e44f1b944f34d41e04362659497c17388 100644 (file)
@@ -3,7 +3,8 @@ use std::io::Write;
 
 use anyhow::{Error};
 
-use pbs_tools::borrow::Tied;
+use proxmox_borrow::Tied;
+
 use pbs_tools::crypt_config::CryptConfig;
 
 pub struct ChecksumWriter<W> {
index 5c87c065d8cc072eca6c0c7c9e6a4e2e38fc0271..439069ffa84efaea70eb519f95c2464d116b5cdc 100644 (file)
@@ -33,6 +33,7 @@ walkdir = "2"
 zstd = { version = "0.6", features = [ "bindgen" ] }
 
 proxmox = { version = "0.14.0", default-features = false, features = [ "tokio" ] }
+proxmox-borrow = "1"
 proxmox-io = { version = "1", features = [ "tokio" ] }
 proxmox-lang = { version = "1" }
 proxmox-time = { version = "1" }
diff --git a/pbs-tools/src/borrow.rs b/pbs-tools/src/borrow.rs
deleted file mode 100644 (file)
index 66b68ad..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/// This ties two values T and U together, such that T does not move and cannot be used as long as
-/// there's an U. This essentially replaces the borrow checker's job for dependent values which
-/// need to be stored together in a struct {}, and is similar to what the 'rental' crate produces.
-pub struct Tied<T, U: ?Sized>(Option<Box<T>>, Option<Box<U>>);
-
-impl<T, U: ?Sized> Drop for Tied<T, U> {
-    fn drop(&mut self) {
-        // let's be explicit about order here!
-        std::mem::drop(self.1.take());
-    }
-}
-
-impl<T, U: ?Sized> Tied<T, U> {
-    /// Takes an owner and a function producing the depending value. The owner will be inaccessible
-    /// until the tied value is resolved. The dependent value is only accessible by reference.
-    pub fn new<F>(owner: T, producer: F) -> Self
-    where
-        F: FnOnce(*mut T) -> Box<U>,
-    {
-        let mut owner = Box::new(owner);
-        let dep = producer(&mut *owner);
-        Tied(Some(owner), Some(dep))
-    }
-
-    pub fn into_boxed_inner(mut self) -> Box<T> {
-        self.1 = None;
-        self.0.take().unwrap()
-    }
-
-    pub fn into_inner(self) -> T {
-        *self.into_boxed_inner()
-    }
-}
-
-impl<T, U: ?Sized> AsRef<U> for Tied<T, U> {
-    fn as_ref(&self) -> &U {
-        self.1.as_ref().unwrap()
-    }
-}
-
-impl<T, U: ?Sized> AsMut<U> for Tied<T, U> {
-    fn as_mut(&mut self) -> &mut U {
-        self.1.as_mut().unwrap()
-    }
-}
-
-impl<T, U: ?Sized> std::ops::Deref for Tied<T, U> {
-    type Target = U;
-
-    fn deref(&self) -> &U {
-        self.as_ref()
-    }
-}
-
-impl<T, U: ?Sized> std::ops::DerefMut for Tied<T, U> {
-    fn deref_mut(&mut self) -> &mut U {
-        self.as_mut()
-    }
-}
index b2bd152c14cdb43ebfcff352e5b4af4210d09992..1a0635d41e626132895bb660e02e7cd6b552362c 100644 (file)
@@ -16,8 +16,7 @@ use nix::sys::stat::Mode;
 use regex::Regex;
 
 use proxmox::sys::error::SysError;
-
-use crate::borrow::Tied;
+use proxmox_borrow::Tied;
 
 pub type DirLockGuard = Dir;
 
index 8ac322dd78a6c353181c483aa41eb66574c97742..f36cc17534e3508cedbc2c5b39ec861c57ea655e 100644 (file)
@@ -1,6 +1,5 @@
 pub mod acl;
 pub mod blocking;
-pub mod borrow;
 pub mod broadcast_future;
 pub mod cert;
 pub mod cli;