Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions signature/src/encoding.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Encoding support.

use crate::{Error, Result};
use crate::Error;

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

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

/// Decode signature from its byte representation.
fn from_bytes(bytes: &Self::Repr) -> Result<Self> {
Self::try_from(bytes.as_ref())
}

/// Encode signature as its byte representation.
fn to_bytes(&self) -> Self::Repr {
self.clone().into()
Expand All @@ -28,11 +23,4 @@ pub trait SignatureEncoding:
fn to_vec(&self) -> Vec<u8> {
self.to_bytes().as_ref().to_vec()
}

/// Encode the signature as a boxed byte slice.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn to_boxed_slice(&self) -> Box<[u8]> {
self.to_vec().into_boxed_slice()
}
}