mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_udp: use Cow<'static, str> for ErrorResponse.message
This commit is contained in:
parent
881579435a
commit
31b88a5e9d
4 changed files with 8 additions and 7 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
use std::io::{self, Cursor, Write};
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
|
|
@ -37,7 +38,7 @@ pub struct ScrapeResponse {
|
|||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
pub struct ErrorResponse {
|
||||
pub transaction_id: TransactionId,
|
||||
pub message: String,
|
||||
pub message: Cow<'static, str>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
|
|
@ -224,7 +225,7 @@ impl Response {
|
|||
|
||||
Ok((ErrorResponse {
|
||||
transaction_id: TransactionId(transaction_id),
|
||||
message: String::from_utf8_lossy(&inner[position..]).into(),
|
||||
message: String::from_utf8_lossy(&inner[position..]).into_owned().into(),
|
||||
})
|
||||
.into())
|
||||
}
|
||||
|
|
@ -262,7 +263,7 @@ impl Response {
|
|||
}
|
||||
_ => Ok((ErrorResponse {
|
||||
transaction_id: TransactionId(transaction_id),
|
||||
message: "Invalid action".to_string(),
|
||||
message: "Invalid action".into(),
|
||||
})
|
||||
.into()),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue