From 0a1061ae007437eaa1ed06cc7905bf0b698319e1 Mon Sep 17 00:00:00 2001 From: lukasmittag Date: Tue, 1 Oct 2024 13:14:22 +0200 Subject: [PATCH] Move conversion of UpdatError --- databroker/src/broker.rs | 31 ------------------- .../src/grpc/kuksa_val_v2/conversions.rs | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) 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), + ), + } + } +}