aquatic_udp: use Cow<'static, str> for ErrorResponse.message

This commit is contained in:
Joakim Frostegård 2021-10-16 00:16:00 +02:00
parent 881579435a
commit 31b88a5e9d
4 changed files with 8 additions and 7 deletions

View file

@ -52,7 +52,7 @@ pub fn handle_announce_requests(
} else {
Response::Error(ErrorResponse {
transaction_id: request.transaction_id,
message: "Info hash not allowed".to_string(),
message: "Info hash not allowed".into(),
})
};

View file

@ -143,6 +143,6 @@ pub fn run_request_worker(
fn create_invalid_connection_response(transaction_id: TransactionId) -> Response {
Response::Error(ErrorResponse {
transaction_id,
message: "Connection invalid or expired".to_string(),
message: "Connection invalid or expired".into(),
})
}

View file

@ -152,9 +152,9 @@ fn read_requests(
if let Some(transaction_id) = err.transaction_id {
let opt_message = if err.error.is_some() {
Some("Parse error".to_string())
Some("Parse error".into())
} else if let Some(message) = err.message {
Some(message)
Some(message.into())
} else {
None
};