Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum KvResponse {
Ok,
BeginTx { tx_id: u64 },
Get { key: Vec<u8> },
Err { error: KvError },
Err(KvError),
}

#[derive(Debug, Serialize, Deserialize, Error)]
Expand Down Expand Up @@ -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)),
}
}
Expand Down Expand Up @@ -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)),
}
}
Expand All @@ -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)),
}
}
Expand All @@ -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)),
}
}
Expand All @@ -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)),
}
}
Expand Down Expand Up @@ -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)),
}
}
Expand All @@ -262,7 +262,7 @@ pub fn remove_db(package_id: PackageId, db: &str, timeout: Option<u64>) -> 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)),
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum SqliteResponse {
Ok,
Read,
BeginTx { tx_id: u64 },
Err { error: SqliteError },
Err(SqliteError),
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn open(package_id: PackageId, db: &str, timeout: Option<u64>) -> 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
Expand Down Expand Up @@ -272,7 +272,7 @@ pub fn remove_db(package_id: PackageId, db: &str, timeout: Option<u64>) -> 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
Expand Down
10 changes: 6 additions & 4 deletions src/vfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize, VfsError> {
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 {
Expand Down Expand Up @@ -216,7 +216,7 @@ impl File {
/// Seek file to position.
/// Returns the new position.
pub fn seek(&mut self, pos: SeekFrom) -> Result<u64, VfsError> {
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 {
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/vfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -79,7 +79,7 @@ pub enum VfsResponse {
Ok,
Err(VfsError),
Read,
SeekFrom(u64),
SeekFrom { new_offset: u64 },
ReadDir(Vec<DirEntry>),
ReadToString(String),
Metadata(FileMetadata),
Expand Down
Loading