Dependencies bump and compilation fixes

This commit is contained in:
Roey Darwish Dror
2020-03-01 21:25:26 +02:00
parent 11c5b04677
commit 7c88f4527d
10 changed files with 199 additions and 237 deletions

View File

@@ -54,7 +54,7 @@ pub struct CreateCommand {
/// Create an image with a certain size in the given path instead of using an actual block device
#[structopt(
long = "image",
parse(try_from_str = "parse_bytes"),
parse(try_from_str = parse_bytes),
value_name = "size",
requires = "path"
)]

View File

@@ -100,7 +100,7 @@ pub enum ErrorKind {
}
impl Fail for Error {
fn cause(&self) -> Option<&Fail> {
fn cause(&self) -> Option<&dyn Fail> {
self.inner.cause()
}

View File

@@ -202,9 +202,9 @@ fn create(command: CreateCommand) -> Result<(), Error> {
};
let root_partition = if let Some(e) = encrypted_root.as_ref() {
e as &BlockDevice
e as &dyn BlockDevice
} else {
&root_partition_base as &BlockDevice
&root_partition_base as &dyn BlockDevice
};
let root_filesystem = Filesystem::format(root_partition, FilesystemType::Ext4, &mkext4)?;
@@ -381,9 +381,9 @@ fn create(command: CreateCommand) -> Result<(), Error> {
fn chroot(command: ChrootCommand) -> Result<(), Error> {
let arch_chroot = Tool::find("arch-chroot")?;
let mut cryptsetup;
let cryptsetup;
let mut loop_device: Option<LoopDevice>;
let loop_device: Option<LoopDevice>;
let storage_device =
match storage::StorageDevice::from_path(&command.block_device, command.allow_non_removable)
{
@@ -414,9 +414,9 @@ fn chroot(command: ChrootCommand) -> Result<(), Error> {
};
let root_partition = if let Some(e) = encrypted_root.as_ref() {
e as &BlockDevice
e as &dyn BlockDevice
} else {
&root_partition_base as &BlockDevice
&root_partition_base as &dyn BlockDevice
};
let root_filesystem = Filesystem::from_partition(root_partition, FilesystemType::Ext4);
@@ -491,7 +491,7 @@ fn main() {
}
Err(error) => {
error!("{}", error);
for cause in (&error as &Fail).iter_causes() {
for cause in (&error as &dyn Fail).iter_causes() {
error!("Caused by: {}", cause);
}
exit(1);

View File

@@ -17,11 +17,11 @@ pub struct EncryptedDevice<'t, 'o> {
cryptsetup: &'t Tool,
name: String,
path: PathBuf,
origin: PhantomData<&'o BlockDevice>,
origin: PhantomData<&'o dyn BlockDevice>,
}
impl<'t, 'o> EncryptedDevice<'t, 'o> {
pub fn prepare(cryptsetup: &Tool, device: &BlockDevice) -> Result<(), Error> {
pub fn prepare(cryptsetup: &Tool, device: &dyn BlockDevice) -> Result<(), Error> {
debug!("Preparing encrypted device in {}", device.path().display());
cryptsetup
.execute()
@@ -35,7 +35,7 @@ impl<'t, 'o> EncryptedDevice<'t, 'o> {
pub fn open(
cryptsetup: &'t Tool,
device: &'o BlockDevice,
device: &'o dyn BlockDevice,
name: String,
) -> Result<EncryptedDevice<'t, 'o>, Error> {
debug!(
@@ -85,7 +85,7 @@ impl<'t, 'o> BlockDevice for EncryptedDevice<'t, 'o> {
}
}
pub fn is_encrypted_device(device: &BlockDevice) -> Result<bool, Error> {
pub fn is_encrypted_device(device: &dyn BlockDevice) -> Result<bool, Error> {
let mut f = fs::OpenOptions::new()
.read(true)
.write(false)

View File

@@ -23,12 +23,12 @@ impl FilesystemType {
#[derive(Debug)]
pub struct Filesystem<'a> {
fs_type: FilesystemType,
block: &'a BlockDevice,
block: &'a dyn BlockDevice,
}
impl<'a> Filesystem<'a> {
pub fn format(
block: &'a BlockDevice,
block: &'a dyn BlockDevice,
fs_type: FilesystemType,
mkfs: &Tool,
) -> Result<Self, Error> {
@@ -43,11 +43,11 @@ impl<'a> Filesystem<'a> {
Ok(Self { fs_type, block })
}
pub fn from_partition(block: &'a BlockDevice, fs_type: FilesystemType) -> Self {
pub fn from_partition(block: &'a dyn BlockDevice, fs_type: FilesystemType) -> Self {
Self { fs_type, block }
}
pub fn block(&self) -> &BlockDevice {
pub fn block(&self) -> &dyn BlockDevice {
self.block
}

View File

@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
#[derive(Debug)]
pub struct Partition<'a> {
path: PathBuf,
origin: PhantomData<&'a Origin>,
origin: PhantomData<&'a dyn Origin>,
}
impl<'a> Partition<'a> {

View File

@@ -81,7 +81,7 @@ mod tests {
#[test]
fn sanity() {
let devices = get_removable_devices().unwrap();
let devices = get_storage_devices(false).unwrap();
println!("{:?}", devices);
}
}

View File

@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
pub struct StorageDevice<'a> {
name: String,
path: PathBuf,
origin: PhantomData<&'a Origin>,
origin: PhantomData<&'a dyn Origin>,
}
impl<'a> StorageDevice<'a> {