Skip to content

Commit c394f3d

Browse files
authored
Merge pull request #20 from mathstuf/avoid-force-alloc
keytypes: use Cow<'static, str> to avoid forcing allocation
2 parents 6edd4f7 + 3df3413 commit c394f3d

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/keytypes/blacklist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum HashType {
5252
/// x509 data
5353
Tbs,
5454
/// Custom hash type
55-
Other(String),
55+
Other(Cow<'static, str>),
5656
}
5757

5858
impl HashType {

src/keytypes/dns_resolver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum QueryType {
5353
/// An AFS database address.
5454
AFSDB,
5555
/// A custom DNS record.
56-
Other(String),
56+
Other(Cow<'static, str>),
5757
}
5858

5959
impl QueryType {
@@ -82,15 +82,15 @@ pub struct Description {
8282
/// If not specified, `A` and `AAAA` entries will be found.
8383
pub query_type: Option<QueryType>,
8484
/// The name to resolve.
85-
pub name: String,
85+
pub name: Cow<'static, str>,
8686
}
8787

8888
impl KeyDescription for Description {
8989
fn description(&self) -> Cow<str> {
90-
Cow::Owned(if let Some(ref query_type) = self.query_type {
91-
format!("{}:{}", query_type.name(), self.name)
90+
if let Some(ref query_type) = self.query_type {
91+
Cow::Owned(format!("{}:{}", query_type.name(), self.name))
9292
} else {
9393
self.name.clone()
94-
})
94+
}
9595
}
9696
}

src/keytypes/encrypted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub enum Payload {
115115
/// The type of key to use for encrypting the new key.
116116
keytype: MasterKeyType,
117117
/// The description of the key to use for encrypting the new key.
118-
description: String,
118+
description: Cow<'static, str>,
119119
/// The size of the key to generate.
120120
keylen: usize,
121121
},
@@ -136,7 +136,7 @@ pub enum Payload {
136136
/// Must be the same type as when the key was created.
137137
keytype: MasterKeyType,
138138
/// The description of the key to use for encrypting the new key.
139-
description: String,
139+
description: Cow<'static, str>,
140140
},
141141
}
142142

src/keytypes/logon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ impl KeyType for Logon {
5353
#[derive(Debug, Clone, PartialEq, Eq)]
5454
pub struct Description {
5555
/// They subtype of the key.
56-
pub subtype: String,
56+
pub subtype: Cow<'static, str>,
5757
/// The description of the key.
58-
pub description: String,
58+
pub description: Cow<'static, str>,
5959
}
6060

6161
impl KeyDescription for Description {

0 commit comments

Comments
 (0)