core: move DbOrUser to types, wrap item name in struct
This commit is contained in:
@@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::core::{
|
||||
protocol::request_validation::{DbOrUser, NameValidationError, OwnerValidationError},
|
||||
types::MySQLUser,
|
||||
protocol::request_validation::{NameValidationError, OwnerValidationError},
|
||||
types::{DbOrUser, MySQLUser},
|
||||
};
|
||||
|
||||
pub type DropUsersRequest = Vec<MySQLUser>;
|
||||
@@ -59,8 +59,12 @@ pub fn print_drop_users_output_status_json(output: &DropUsersResponse) {
|
||||
impl DropUserError {
|
||||
pub fn to_error_message(&self, username: &MySQLUser) -> String {
|
||||
match self {
|
||||
DropUserError::SanitizationError(err) => err.to_error_message(username, DbOrUser::User),
|
||||
DropUserError::OwnershipError(err) => err.to_error_message(username, DbOrUser::User),
|
||||
DropUserError::SanitizationError(err) => {
|
||||
err.to_error_message(DbOrUser::User(username.clone()))
|
||||
}
|
||||
DropUserError::OwnershipError(err) => {
|
||||
err.to_error_message(DbOrUser::User(username.clone()))
|
||||
}
|
||||
DropUserError::UserDoesNotExist => {
|
||||
format!("User '{}' does not exist.", username)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user