Create constant for ut_metadata
This commit is contained in:
parent
8dc8c1e35d
commit
19e944a697
2 changed files with 4 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ use bytes::Bytes;
|
|||
use clone_to_owned::CloneToOwned;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use crate::MY_EXTENDED_UT_METADATA;
|
||||
use crate::{EXTENDED_UT_METADATA_KEY, MY_EXTENDED_UT_METADATA};
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
pub struct ExtendedHandshake<ByteBuf: Eq + std::hash::Hash> {
|
||||
|
|
@ -39,7 +39,7 @@ pub struct ExtendedHandshake<ByteBuf: Eq + std::hash::Hash> {
|
|||
impl ExtendedHandshake<ByteBuf<'static>> {
|
||||
pub fn new() -> Self {
|
||||
let mut features = HashMap::new();
|
||||
features.insert(ByteBuf(b"ut_metadata"), MY_EXTENDED_UT_METADATA);
|
||||
features.insert(ByteBuf(EXTENDED_UT_METADATA_KEY), MY_EXTENDED_UT_METADATA);
|
||||
Self {
|
||||
m: features,
|
||||
..Default::default()
|
||||
|
|
@ -56,7 +56,7 @@ where
|
|||
}
|
||||
|
||||
pub fn ut_metadata(&self) -> Option<u8> {
|
||||
self.get_msgid(b"ut_metadata")
|
||||
self.get_msgid(EXTENDED_UT_METADATA_KEY)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ const MSGID_PIECE: u8 = 7;
|
|||
const MSGID_CANCEL: u8 = 8;
|
||||
const MSGID_EXTENDED: u8 = 20;
|
||||
|
||||
pub const EXTENDED_UT_METADATA_KEY: &[u8] = b"ut_metadata";
|
||||
pub const MY_EXTENDED_UT_METADATA: u8 = 3;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue