Skip to content

Commit 2fb70ac

Browse files
authored
signature: simplify encoding trait (#1149)
Removes the `from_bytes` and `to_boxed_slice` methods, as `TryFrom` and `to_vec().into_boxed_slice()` provide equivalent functionality.
1 parent 45f1bab commit 2fb70ac

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

signature/src/encoding.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Encoding support.
22
3-
use crate::{Error, Result};
3+
use crate::Error;
44

55
#[cfg(feature = "alloc")]
6-
use alloc::{boxed::Box, vec::Vec};
6+
use alloc::vec::Vec;
77

88
/// Support for decoding/encoding signatures as bytes.
99
pub trait SignatureEncoding:
@@ -12,11 +12,6 @@ pub trait SignatureEncoding:
1212
/// Byte representation of a signature.
1313
type Repr: 'static + AsRef<[u8]> + Clone + Send + Sync;
1414

15-
/// Decode signature from its byte representation.
16-
fn from_bytes(bytes: &Self::Repr) -> Result<Self> {
17-
Self::try_from(bytes.as_ref())
18-
}
19-
2015
/// Encode signature as its byte representation.
2116
fn to_bytes(&self) -> Self::Repr {
2217
self.clone().into()
@@ -28,11 +23,4 @@ pub trait SignatureEncoding:
2823
fn to_vec(&self) -> Vec<u8> {
2924
self.to_bytes().as_ref().to_vec()
3025
}
31-
32-
/// Encode the signature as a boxed byte slice.
33-
#[cfg(feature = "alloc")]
34-
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
35-
fn to_boxed_slice(&self) -> Box<[u8]> {
36-
self.to_vec().into_boxed_slice()
37-
}
3826
}

0 commit comments

Comments
 (0)