Address inline review comments.

This commit is contained in:
ryneeverett
2023-01-15 13:28:00 -05:00
committed by Dustin J. Mitchell
parent c061d926bb
commit f56296ea93
5 changed files with 15 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ use thiserror::Error;
pub enum Error { pub enum Error {
/// A crypto-related error /// A crypto-related error
#[error("Crypto Error: {0}")] #[error("Crypto Error: {0}")]
Crypto(String), Server(String),
/// A task-database-related error /// A task-database-related error
#[error("Task Database Error: {0}")] #[error("Task Database Error: {0}")]
Database(String), Database(String),
@@ -18,7 +18,7 @@ pub enum Error {
OutOfSync, OutOfSync,
/// A usage error /// A usage error
#[error("User Error: {0}")] #[error("User Error: {0}")]
UserError(String), Usage(String),
/// Error conversions. /// Error conversions.
#[error(transparent)] #[error(transparent)]
@@ -35,4 +35,4 @@ pub enum Error {
Sqlite(#[from] crate::storage::sqlite::SqliteError), Sqlite(#[from] crate::storage::sqlite::SqliteError),
} }
pub type Result<T> = core::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;

View File

@@ -136,12 +136,12 @@ struct Envelope<'a> {
impl<'a> Envelope<'a> { impl<'a> Envelope<'a> {
fn from_bytes(buf: &'a [u8]) -> Result<Envelope<'a>> { fn from_bytes(buf: &'a [u8]) -> Result<Envelope<'a>> {
if buf.len() <= 1 + aead::NONCE_LEN { if buf.len() <= 1 + aead::NONCE_LEN {
return Err(Error::Crypto(String::from("envelope is too small"))); return Err(Error::Server(String::from("envelope is too small")));
} }
let version = buf[0]; let version = buf[0];
if version != ENVELOPE_VERSION { if version != ENVELOPE_VERSION {
return Err(Error::Crypto(format!( return Err(Error::Server(format!(
"unrecognized encryption envelope version {}", "unrecognized encryption envelope version {}",
version version
))); )));
@@ -191,7 +191,7 @@ impl Sealed {
payload, payload,
}) })
} else { } else {
Err(Error::Crypto(String::from( Err(Error::Server(String::from(
"Response did not have expected content-type", "Response did not have expected content-type",
))) )))
} }

View File

@@ -113,7 +113,7 @@ struct Txn<'t> {
} }
impl<'t> Txn<'t> { impl<'t> Txn<'t> {
fn get_txn(&self) -> core::result::Result<&rusqlite::Transaction<'t>, SqliteError> { fn get_txn(&self) -> std::result::Result<&rusqlite::Transaction<'t>, SqliteError> {
self.txn self.txn
.as_ref() .as_ref()
.ok_or(SqliteError::TransactionAlreadyCommitted) .ok_or(SqliteError::TransactionAlreadyCommitted)
@@ -305,7 +305,7 @@ impl<'t> StorageTxn for Txn<'t> {
}) })
.context("Get working set query")?; .context("Get working set query")?;
let rows: Vec<core::result::Result<(usize, Uuid), _>> = rows.collect(); let rows: Vec<std::result::Result<(usize, Uuid), _>> = rows.collect();
let mut res = Vec::with_capacity(rows.len()); let mut res = Vec::with_capacity(rows.len());
for _ in 0..self for _ in 0..self
.get_next_working_set_number() .get_next_working_set_number()

View File

@@ -418,7 +418,7 @@ impl<'r> TaskMut<'r> {
/// Add a tag to this task. Does nothing if the tag is already present. /// Add a tag to this task. Does nothing if the tag is already present.
pub fn add_tag(&mut self, tag: &Tag) -> Result<()> { pub fn add_tag(&mut self, tag: &Tag) -> Result<()> {
if tag.is_synthetic() { if tag.is_synthetic() {
return Err(Error::UserError(String::from( return Err(Error::Usage(String::from(
"Synthetic tags cannot be modified", "Synthetic tags cannot be modified",
))); )));
} }
@@ -428,7 +428,7 @@ impl<'r> TaskMut<'r> {
/// Remove a tag from this task. Does nothing if the tag is not present. /// Remove a tag from this task. Does nothing if the tag is not present.
pub fn remove_tag(&mut self, tag: &Tag) -> Result<()> { pub fn remove_tag(&mut self, tag: &Tag) -> Result<()> {
if tag.is_synthetic() { if tag.is_synthetic() {
return Err(Error::UserError(String::from( return Err(Error::Usage(String::from(
"Synthetic tags cannot be modified", "Synthetic tags cannot be modified",
))); )));
} }
@@ -476,7 +476,7 @@ impl<'r> TaskMut<'r> {
) -> Result<()> { ) -> Result<()> {
let key = key.into(); let key = key.into();
if Task::is_known_key(&key) { if Task::is_known_key(&key) {
return Err(Error::UserError(format!( return Err(Error::Usage(format!(
"Property name {} as special meaning in a task and cannot be used as a UDA", "Property name {} as special meaning in a task and cannot be used as a UDA",
key key
))); )));
@@ -488,7 +488,7 @@ impl<'r> TaskMut<'r> {
pub fn remove_legacy_uda(&mut self, key: impl Into<String>) -> Result<()> { pub fn remove_legacy_uda(&mut self, key: impl Into<String>) -> Result<()> {
let key = key.into(); let key = key.into();
if Task::is_known_key(&key) { if Task::is_known_key(&key) {
return Err(Error::UserError(format!( return Err(Error::Usage(format!(
"Property name {} as special meaning in a task and cannot be used as a UDA", "Property name {} as special meaning in a task and cannot be used as a UDA",
key key
))); )));

View File

@@ -10,7 +10,7 @@ use uuid::Uuid;
pub(super) struct SnapshotTasks(Vec<(Uuid, TaskMap)>); pub(super) struct SnapshotTasks(Vec<(Uuid, TaskMap)>);
impl Serialize for SnapshotTasks { impl Serialize for SnapshotTasks {
fn serialize<'a, S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error> fn serialize<'a, S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where where
S: Serializer, S: Serializer,
{ {
@@ -31,7 +31,7 @@ impl<'de> Visitor<'de> for TaskDbVisitor {
formatter.write_str("a map representing a task snapshot") formatter.write_str("a map representing a task snapshot")
} }
fn visit_map<M>(self, mut access: M) -> core::result::Result<Self::Value, M::Error> fn visit_map<M>(self, mut access: M) -> std::result::Result<Self::Value, M::Error>
where where
M: MapAccess<'de>, M: MapAccess<'de>,
{ {
@@ -46,7 +46,7 @@ impl<'de> Visitor<'de> for TaskDbVisitor {
} }
impl<'de> Deserialize<'de> for SnapshotTasks { impl<'de> Deserialize<'de> for SnapshotTasks {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,
{ {