diff --git a/src/kv.rs b/src/kv.rs index 516880c..325c53c 100644 --- a/src/kv.rs +++ b/src/kv.rs @@ -30,7 +30,7 @@ pub enum KvResponse { Ok, BeginTx { tx_id: u64 }, Get { key: Vec }, - Err { error: KvError }, + Err(KvError), } #[derive(Debug, Serialize, Deserialize, Error)] @@ -93,7 +93,7 @@ where .map_err(|e| anyhow::anyhow!("Failed to deserialize value: {}", e))?; Ok(value) } - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -122,7 +122,7 @@ where match response { KvResponse::Ok => Ok(()), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -148,7 +148,7 @@ where match response { KvResponse::Ok => Ok(()), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -173,7 +173,7 @@ where match response { KvResponse::BeginTx { tx_id } => Ok(tx_id), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -198,7 +198,7 @@ where match response { KvResponse::Ok => Ok(()), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -235,7 +235,7 @@ where timeout, _marker: PhantomData, }), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } @@ -262,7 +262,7 @@ pub fn remove_db(package_id: PackageId, db: &str, timeout: Option) -> anyho match response { KvResponse::Ok => Ok(()), - KvResponse::Err { error } => Err(error.into()), + KvResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), } } diff --git a/src/sqlite.rs b/src/sqlite.rs index 4a88a5e..b3060be 100644 --- a/src/sqlite.rs +++ b/src/sqlite.rs @@ -36,7 +36,7 @@ pub enum SqliteResponse { Ok, Read, BeginTx { tx_id: u64 }, - Err { error: SqliteError }, + Err(SqliteError), } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -117,7 +117,7 @@ impl Sqlite { })?; Ok(values) } - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response @@ -151,7 +151,7 @@ impl Sqlite { match response { SqliteResponse::Ok => Ok(()), - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response @@ -179,7 +179,7 @@ impl Sqlite { match response { SqliteResponse::BeginTx { tx_id } => Ok(tx_id), - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response @@ -207,7 +207,7 @@ impl Sqlite { match response { SqliteResponse::Ok => Ok(()), - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response @@ -242,7 +242,7 @@ pub fn open(package_id: PackageId, db: &str, timeout: Option) -> anyhow::Re db: db.to_string(), timeout, }), - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response @@ -272,7 +272,7 @@ pub fn remove_db(package_id: PackageId, db: &str, timeout: Option) -> anyho match response { SqliteResponse::Ok => Ok(()), - SqliteResponse::Err { error } => Err(error.into()), + SqliteResponse::Err(error) => Err(error.into()), _ => Err(anyhow::anyhow!( "sqlite: unexpected response {:?}", response diff --git a/src/vfs/file.rs b/src/vfs/file.rs index e73c071..8a6ad07 100644 --- a/src/vfs/file.rs +++ b/src/vfs/file.rs @@ -81,9 +81,9 @@ impl File { /// Read into buffer from current cursor position /// Returns the amount of bytes read. pub fn read_at(&self, buffer: &mut [u8]) -> Result { - let length = buffer.len(); + let length = buffer.len() as u64; - let message = vfs_request(&self.path, VfsAction::ReadExact(length as u64)) + let message = vfs_request(&self.path, VfsAction::ReadExact { length }) .send_and_await_response(self.timeout) .unwrap() .map_err(|e| VfsError::IOError { @@ -216,7 +216,7 @@ impl File { /// Seek file to position. /// Returns the new position. pub fn seek(&mut self, pos: SeekFrom) -> Result { - let message = vfs_request(&self.path, VfsAction::Seek { seek_from: pos }) + let message = vfs_request(&self.path, VfsAction::Seek(pos)) .send_and_await_response(self.timeout) .unwrap() .map_err(|e| VfsError::IOError { @@ -225,7 +225,9 @@ impl File { })?; match parse_response(message.body())? { - VfsResponse::SeekFrom(new_pos) => Ok(new_pos), + VfsResponse::SeekFrom { + new_offset: new_pos, + } => Ok(new_pos), VfsResponse::Err(e) => Err(e), _ => Err(VfsError::ParseError { error: "unexpected response".to_string(), diff --git a/src/vfs/mod.rs b/src/vfs/mod.rs index 6fdd5b7..f6b6319 100644 --- a/src/vfs/mod.rs +++ b/src/vfs/mod.rs @@ -32,9 +32,9 @@ pub enum VfsAction { Read, ReadDir, ReadToEnd, - ReadExact(u64), + ReadExact { length: u64 }, ReadToString, - Seek { seek_from: SeekFrom }, + Seek(SeekFrom), RemoveFile, RemoveDir, RemoveDirAll, @@ -79,7 +79,7 @@ pub enum VfsResponse { Ok, Err(VfsError), Read, - SeekFrom(u64), + SeekFrom { new_offset: u64 }, ReadDir(Vec), ReadToString(String), Metadata(FileMetadata),