aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/error.rs21
-rw-r--r--src/api/s3_bucket.rs6
-rw-r--r--src/api/s3_delete.rs2
-rw-r--r--src/api/s3_put.rs6
4 files changed, 17 insertions, 18 deletions
diff --git a/src/api/error.rs b/src/api/error.rs
index eaa6c3a1..a49ba211 100644
--- a/src/api/error.rs
+++ b/src/api/error.rs
@@ -8,7 +8,6 @@ use garage_util::error::Error as GarageError;
use crate::encoding::*;
/// Errors of this crate
-#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Error)]
pub enum Error {
// Category: internal error
@@ -22,7 +21,7 @@ pub enum Error {
/// Error related to HTTP
#[error(display = "Internal error (HTTP error): {}", _0)]
- HTTP(#[error(source)] http::Error),
+ Http(#[error(source)] http::Error),
// Category: cannot process
/// No proper api key was used, or the signature was invalid
@@ -40,11 +39,11 @@ pub enum Error {
// Category: bad request
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
#[error(display = "Invalid UTF-8: {}", _0)]
- InvalidUTF8Str(#[error(source)] std::str::Utf8Error),
+ InvalidUtf8Str(#[error(source)] std::str::Utf8Error),
/// The request used an invalid path
#[error(display = "Invalid UTF-8: {}", _0)]
- InvalidUTF8String(#[error(source)] std::string::FromUtf8Error),
+ InvalidUtf8String(#[error(source)] std::string::FromUtf8Error),
/// Some base64 encoded data was badly encoded
#[error(display = "Invalid base64: {}", _0)]
@@ -52,7 +51,7 @@ pub enum Error {
/// The client sent invalid XML data
#[error(display = "Invalid XML: {}", _0)]
- InvalidXML(String),
+ InvalidXml(String),
/// The client sent a header with invalid value
#[error(display = "Invalid header value: {}", _0)]
@@ -69,13 +68,13 @@ pub enum Error {
impl From<roxmltree::Error> for Error {
fn from(err: roxmltree::Error) -> Self {
- Self::InvalidXML(format!("{}", err))
+ Self::InvalidXml(format!("{}", err))
}
}
impl From<quick_xml::de::DeError> for Error {
fn from(err: quick_xml::de::DeError) -> Self {
- Self::InvalidXML(format!("{}", err))
+ Self::InvalidXml(format!("{}", err))
}
}
@@ -85,8 +84,8 @@ impl Error {
match self {
Error::NotFound => StatusCode::NOT_FOUND,
Error::Forbidden(_) => StatusCode::FORBIDDEN,
- Error::InternalError(GarageError::RPC(_)) => StatusCode::SERVICE_UNAVAILABLE,
- Error::InternalError(_) | Error::Hyper(_) | Error::HTTP(_) => {
+ Error::InternalError(GarageError::Rpc(_)) => StatusCode::SERVICE_UNAVAILABLE,
+ Error::InternalError(_) | Error::Hyper(_) | Error::Http(_) => {
StatusCode::INTERNAL_SERVER_ERROR
}
_ => StatusCode::BAD_REQUEST,
@@ -98,8 +97,8 @@ impl Error {
Error::NotFound => "NoSuchKey",
Error::Forbidden(_) => "AccessDenied",
Error::AuthorizationHeaderMalformed(_) => "AuthorizationHeaderMalformed",
- Error::InternalError(GarageError::RPC(_)) => "ServiceUnavailable",
- Error::InternalError(_) | Error::Hyper(_) | Error::HTTP(_) => "InternalError",
+ Error::InternalError(GarageError::Rpc(_)) => "ServiceUnavailable",
+ Error::InternalError(_) | Error::Hyper(_) | Error::Http(_) => "InternalError",
_ => "InvalidRequest",
}
}
diff --git a/src/api/s3_bucket.rs b/src/api/s3_bucket.rs
index d1a4425a..e7d89698 100644
--- a/src/api/s3_bucket.rs
+++ b/src/api/s3_bucket.rs
@@ -34,7 +34,7 @@ struct DisplayName {
pub body: String,
}
#[derive(Debug, Serialize, PartialEq)]
-struct ID {
+struct Id {
#[serde(rename = "$value")]
pub body: String,
}
@@ -43,7 +43,7 @@ struct Owner {
#[serde(rename = "DisplayName")]
display_name: DisplayName,
#[serde(rename = "ID")]
- id: ID,
+ id: Id,
}
#[derive(Debug, Serialize, PartialEq)]
struct BucketList {
@@ -80,7 +80,7 @@ pub fn handle_list_buckets(api_key: &Key) -> Result<Response<Body>, Error> {
display_name: DisplayName {
body: api_key.name.get().to_string(),
},
- id: ID {
+ id: Id {
body: api_key.key_id.to_string(),
},
},
diff --git a/src/api/s3_delete.rs b/src/api/s3_delete.rs
index 85bb7692..9d2a67f5 100644
--- a/src/api/s3_delete.rs
+++ b/src/api/s3_delete.rs
@@ -17,7 +17,7 @@ async fn handle_delete_internal(
garage: &Garage,
bucket: &str,
key: &str,
-) -> Result<(UUID, UUID), Error> {
+) -> Result<(Uuid, Uuid), Error> {
let object = garage
.object_table
.get(&bucket.to_string(), &key.to_string())
diff --git a/src/api/s3_put.rs b/src/api/s3_put.rs
index c39189c5..bb6cf579 100644
--- a/src/api/s3_put.rs
+++ b/src/api/s3_put.rs
@@ -305,7 +305,7 @@ impl BodyChunker {
}
}
-pub fn put_response(version_uuid: UUID, md5sum_hex: String) -> Response<Body> {
+pub fn put_response(version_uuid: Uuid, md5sum_hex: String) -> Response<Body> {
Response::builder()
.header("x-amz-version-id", hex::encode(version_uuid))
.header("ETag", format!("\"{}\"", md5sum_hex))
@@ -633,14 +633,14 @@ pub(crate) fn get_headers(req: &Request<Body>) -> Result<ObjectVersionHeaders, E
})
}
-fn decode_upload_id(id: &str) -> Result<UUID, Error> {
+fn decode_upload_id(id: &str) -> Result<Uuid, Error> {
let id_bin = hex::decode(id).ok_or_bad_request("Invalid upload ID")?;
if id_bin.len() != 32 {
return None.ok_or_bad_request("Invalid upload ID");
}
let mut uuid = [0u8; 32];
uuid.copy_from_slice(&id_bin[..]);
- Ok(UUID::from(uuid))
+ Ok(Uuid::from(uuid))
}
#[derive(Debug)]