summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-06 13:35:35 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-06 13:39:56 +0100
commit2a75428b44fd56616342a786cc33dd66145f6228 (patch)
tree3ccf25024106dec1d81954aa47b3e9bf152d124f /openpgp/src/packet
parentd6f553a2f3063d2995fbd91ed137cc876d7ecdc0 (diff)
openpgp: Rename consuming conversion functions.
- Rename functions that consume their receiver but are called .to_...() to .into_...(). - For the packet types, simply drop the conversion function in favor of using the From trait. - Fixes #160.
Diffstat (limited to 'openpgp/src/packet')
-rw-r--r--openpgp/src/packet/aed.rs7
-rw-r--r--openpgp/src/packet/compressed_data.rs7
-rw-r--r--openpgp/src/packet/literal.rs7
-rw-r--r--openpgp/src/packet/mdc.rs7
-rw-r--r--openpgp/src/packet/one_pass_sig.rs7
-rw-r--r--openpgp/src/packet/pkesk.rs7
-rw-r--r--openpgp/src/packet/seip.rs7
-rw-r--r--openpgp/src/packet/signature/mod.rs7
-rw-r--r--openpgp/src/packet/signature/subpacket.rs2
-rw-r--r--openpgp/src/packet/skesk.rs13
-rw-r--r--openpgp/src/packet/unknown.rs7
-rw-r--r--openpgp/src/packet/user_attribute.rs7
-rw-r--r--openpgp/src/packet/userid.rs7
13 files changed, 14 insertions, 78 deletions
diff --git a/openpgp/src/packet/aed.rs b/openpgp/src/packet/aed.rs
index 8edc4dc2..7bf23bcb 100644
--- a/openpgp/src/packet/aed.rs
+++ b/openpgp/src/packet/aed.rs
@@ -121,16 +121,11 @@ impl AED {
pub fn set_iv(&mut self, iv: Box<[u8]>) {
self.iv = iv;
}
-
- /// Convert the `AED` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::AED(self)
- }
}
impl From<AED> for Packet {
fn from(s: AED) -> Self {
- s.to_packet()
+ Packet::AED(s)
}
}
diff --git a/openpgp/src/packet/compressed_data.rs b/openpgp/src/packet/compressed_data.rs
index 36771232..cda495ba 100644
--- a/openpgp/src/packet/compressed_data.rs
+++ b/openpgp/src/packet/compressed_data.rs
@@ -76,16 +76,11 @@ impl CompressedData {
self.common.children.as_mut().unwrap().insert(i, packet);
self
}
-
- /// Convert the `CompressedData` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::CompressedData(self)
- }
}
impl From<CompressedData> for Packet {
fn from(s: CompressedData) -> Self {
- s.to_packet()
+ Packet::CompressedData(s)
}
}
diff --git a/openpgp/src/packet/literal.rs b/openpgp/src/packet/literal.rs
index 05a8047d..48b31775 100644
--- a/openpgp/src/packet/literal.rs
+++ b/openpgp/src/packet/literal.rs
@@ -163,16 +163,11 @@ impl Literal {
self.date = timestamp.map(|t| t.canonicalize())
.unwrap_or(time::Tm::from_pgp(0));
}
-
- /// Convert the `Literal` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::Literal(self)
- }
}
impl From<Literal> for Packet {
fn from(s: Literal) -> Self {
- s.to_packet()
+ Packet::Literal(s)
}
}
diff --git a/openpgp/src/packet/mdc.rs b/openpgp/src/packet/mdc.rs
index 0a217639..1ee61ed5 100644
--- a/openpgp/src/packet/mdc.rs
+++ b/openpgp/src/packet/mdc.rs
@@ -56,11 +56,6 @@ impl MDC {
&self.computed_hash[..]
}
- /// Converts the `MDC` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::MDC(self)
- }
-
/// Returns whether the data protected by the MDC is valid.
pub fn valid(&self) -> bool {
if self.hash == [ 0; 20 ] {
@@ -75,6 +70,6 @@ impl MDC {
impl From<MDC> for Packet {
fn from(s: MDC) -> Self {
- s.to_packet()
+ Packet::MDC(s)
}
}
diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs
index ae174652..d094bb58 100644
--- a/openpgp/src/packet/one_pass_sig.rs
+++ b/openpgp/src/packet/one_pass_sig.rs
@@ -140,16 +140,11 @@ impl OnePassSig {
pub fn set_last_raw(&mut self, last: u8) {
self.last = last;
}
-
- /// Convert the `OnePassSig` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::OnePassSig(self)
- }
}
impl From<OnePassSig> for Packet {
fn from(s: OnePassSig) -> Self {
- s.to_packet()
+ Packet::OnePassSig(s)
}
}
diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs
index 7b77cf7b..eb049bdd 100644
--- a/openpgp/src/packet/pkesk.rs
+++ b/openpgp/src/packet/pkesk.rs
@@ -209,16 +209,11 @@ impl PKESK {
.into())
}
}
-
- /// Convert the `PKESK` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::PKESK(self)
- }
}
impl From<PKESK> for Packet {
fn from(s: PKESK) -> Self {
- s.to_packet()
+ Packet::PKESK(s)
}
}
diff --git a/openpgp/src/packet/seip.rs b/openpgp/src/packet/seip.rs
index 9d27684a..02f0e818 100644
--- a/openpgp/src/packet/seip.rs
+++ b/openpgp/src/packet/seip.rs
@@ -28,16 +28,11 @@ impl SEIP {
pub fn version(&self) -> u8 {
self.version
}
-
- /// Convert the `SEIP` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::SEIP(self)
- }
}
impl From<SEIP> for Packet {
fn from(s: SEIP) -> Self {
- s.to_packet()
+ Packet::SEIP(s)
}
}
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs
index 1bd5b31b..940314e2 100644
--- a/openpgp/src/packet/signature/mod.rs
+++ b/openpgp/src/packet/signature/mod.rs
@@ -796,16 +796,11 @@ impl Signature {
self.verify_hash(signer, self.hash_algo(), &digest[..])
}
-
- /// Convert the `Signature` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::Signature(self)
- }
}
impl From<Signature> for Packet {
fn from(s: Signature) -> Self {
- s.to_packet()
+ Packet::Signature(s)
}
}
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index a082bf0d..48059a62 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -2238,7 +2238,7 @@ impl signature::Builder {
pub fn set_embedded_signature(mut self, signature: Signature)
-> Result<Self> {
self.unhashed_area.replace(Subpacket::new(
- SubpacketValue::EmbeddedSignature(signature.to_packet()),
+ SubpacketValue::EmbeddedSignature(signature.into()),
true)?)?;
Ok(self)
diff --git a/openpgp/src/packet/skesk.rs b/openpgp/src/packet/skesk.rs
index eb4ff03f..f0515cc4 100644
--- a/openpgp/src/packet/skesk.rs
+++ b/openpgp/src/packet/skesk.rs
@@ -173,10 +173,6 @@ impl SKESK4 {
}
/// Convert the `SKESK4` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::SKESK(SKESK::V4(self))
- }
-
/// Derives the key inside this SKESK4 from `password`. Returns a
/// tuple of the symmetric cipher to use with the key and the key
/// itself.
@@ -223,7 +219,7 @@ impl SKESK4 {
impl From<SKESK4> for Packet {
fn from(s: SKESK4) -> Self {
- s.to_packet()
+ Packet::SKESK(SKESK::V4(s))
}
}
@@ -387,16 +383,11 @@ impl SKESK5 {
pub fn set_aead_digest(&mut self, digest: Box<[u8]>) {
self.aead_digest = digest;
}
-
- /// Convert the `SKESK5` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::SKESK(SKESK::V5(self))
- }
}
impl From<SKESK5> for Packet {
fn from(s: SKESK5) -> Self {
- s.to_packet()
+ Packet::SKESK(SKESK::V5(s))
}
}
diff --git a/openpgp/src/packet/unknown.rs b/openpgp/src/packet/unknown.rs
index 0819c375..ca7d40e6 100644
--- a/openpgp/src/packet/unknown.rs
+++ b/openpgp/src/packet/unknown.rs
@@ -52,15 +52,10 @@ impl Unknown {
pub fn set_body(&mut self, data: Vec<u8>) {
self.common.body = Some(data);
}
-
- /// Convert the `Unknown` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::Unknown(self)
- }
}
impl From<Unknown> for Packet {
fn from(s: Unknown) -> Self {
- s.to_packet()
+ Packet::Unknown(s)
}
}
diff --git a/openpgp/src/packet/user_attribute.rs b/openpgp/src/packet/user_attribute.rs
index d07fea66..38007a8c 100644
--- a/openpgp/src/packet/user_attribute.rs
+++ b/openpgp/src/packet/user_attribute.rs
@@ -62,16 +62,11 @@ impl UserAttribute {
pub fn set_user_attribute(&mut self, value: &[u8]) {
self.value = value.to_vec();
}
-
- /// Convert the `UserAttribute` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::UserAttribute(self)
- }
}
impl From<UserAttribute> for Packet {
fn from(s: UserAttribute) -> Self {
- s.to_packet()
+ Packet::UserAttribute(s)
}
}
diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs
index d88b06b2..e3dcf625 100644
--- a/openpgp/src/packet/userid.rs
+++ b/openpgp/src/packet/userid.rs
@@ -83,16 +83,11 @@ impl UserID {
pub fn set_userid(&mut self, userid: &str) {
self.set_userid_from_bytes(userid.as_bytes())
}
-
- /// Convert the `UserID` struct to a `Packet`.
- pub fn to_packet(self) -> Packet {
- Packet::UserID(self)
- }
}
impl From<UserID> for Packet {
fn from(s: UserID) -> Self {
- s.to_packet()
+ Packet::UserID(s)
}
}