#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
#[derive(Default, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_with::serde_as,
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[derive(Debug)]
pub struct Signature(pub BytesM<64>);
impl From<Signature> for BytesM<64> {
#[must_use]
fn from(x: Signature) -> Self {
x.0
}
}
impl From<BytesM<64>> for Signature {
#[must_use]
fn from(x: BytesM<64>) -> Self {
Signature(x)
}
}
impl AsRef<BytesM<64>> for Signature {
#[must_use]
fn as_ref(&self) -> &BytesM<64> {
&self.0
}
}
impl ReadXdr for Signature {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
let i = BytesM::<64>::read_xdr(r)?;
let v = Signature(i);
Ok(v)
})
}
}
impl WriteXdr for Signature {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| self.0.write_xdr(w))
}
}
impl Deref for Signature {
type Target = BytesM<64>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<Signature> for Vec<u8> {
#[must_use]
fn from(x: Signature) -> Self {
x.0 .0
}
}
impl TryFrom<Vec<u8>> for Signature {
type Error = Error;
fn try_from(x: Vec<u8>) -> Result<Self, Error> {
Ok(Signature(x.try_into()?))
}
}
#[cfg(feature = "alloc")]
impl TryFrom<&Vec<u8>> for Signature {
type Error = Error;
fn try_from(x: &Vec<u8>) -> Result<Self, Error> {
Ok(Signature(x.try_into()?))
}
}
impl AsRef<Vec<u8>> for Signature {
#[must_use]
fn as_ref(&self) -> &Vec<u8> {
&self.0 .0
}
}
impl AsRef<[u8]> for Signature {
#[cfg(feature = "alloc")]
#[must_use]
fn as_ref(&self) -> &[u8] {
&self.0 .0
}
#[cfg(not(feature = "alloc"))]
#[must_use]
fn as_ref(&self) -> &[u8] {
self.0 .0
}
}