diff --git a/databroker/src/broker.rs b/databroker/src/broker.rs index faba9423..4e098067 100644 --- a/databroker/src/broker.rs +++ b/databroker/src/broker.rs @@ -43,37 +43,6 @@ pub enum UpdateError { PermissionExpired, } -impl UpdateError { - pub fn to_status_with_code(&self, id: &i32) -> tonic::Status { - match self { - UpdateError::NotFound => tonic::Status::new( - tonic::Code::NotFound, - format!("Signal not found (id: {})", id), - ), - UpdateError::WrongType => tonic::Status::new( - tonic::Code::InvalidArgument, - format!("Wrong type provided (id: {})", id), - ), - UpdateError::OutOfBounds => tonic::Status::new( - tonic::Code::OutOfRange, - format!("Index out of bounds (id: {})", id), - ), - UpdateError::UnsupportedType => tonic::Status::new( - tonic::Code::Unimplemented, - format!("Unsupported type (id: {})", id), - ), - UpdateError::PermissionDenied => tonic::Status::new( - tonic::Code::PermissionDenied, - format!("Permission denied (id: {})", id), - ), - UpdateError::PermissionExpired => tonic::Status::new( - tonic::Code::Unauthenticated, - format!("Permission expired (id: {})", id), - ), - } - } -} - #[derive(Debug, Clone)] pub enum ReadError { NotFound, diff --git a/databroker/src/grpc/kuksa_val_v2/conversions.rs b/databroker/src/grpc/kuksa_val_v2/conversions.rs index bb80817c..d8d89b32 100644 --- a/databroker/src/grpc/kuksa_val_v2/conversions.rs +++ b/databroker/src/grpc/kuksa_val_v2/conversions.rs @@ -278,3 +278,34 @@ impl From for proto::EntryType { } } } + +impl broker::UpdateError { + pub fn to_status_with_code(&self, id: &i32) -> tonic::Status { + match self { + broker::UpdateError::NotFound => tonic::Status::new( + tonic::Code::NotFound, + format!("Signal not found (id: {})", id), + ), + broker::UpdateError::WrongType => tonic::Status::new( + tonic::Code::InvalidArgument, + format!("Wrong type provided (id: {})", id), + ), + broker::UpdateError::OutOfBounds => tonic::Status::new( + tonic::Code::OutOfRange, + format!("Index out of bounds (id: {})", id), + ), + broker::UpdateError::UnsupportedType => tonic::Status::new( + tonic::Code::Unimplemented, + format!("Unsupported type (id: {})", id), + ), + broker::UpdateError::PermissionDenied => tonic::Status::new( + tonic::Code::PermissionDenied, + format!("Permission denied (id: {})", id), + ), + broker::UpdateError::PermissionExpired => tonic::Status::new( + tonic::Code::Unauthenticated, + format!("Permission expired (id: {})", id), + ), + } + } +}