#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[allow(clippy::large_enum_variant)]
pub enum PathPaymentStrictSendResult {
Success(PathPaymentStrictSendResultSuccess),
Malformed,
Underfunded,
SrcNoTrust,
SrcNotAuthorized,
NoDestination,
NoTrust,
NotAuthorized,
LineFull,
NoIssuer(Asset),
TooFewOffers,
OfferCrossSelf,
UnderDestmin,
}
impl PathPaymentStrictSendResult {
#[must_use]
pub const fn discriminant(&self) -> PathPaymentStrictSendResultCode {
#[allow(clippy::match_same_arms)]
match self {
Self::Success(_) => PathPaymentStrictSendResultCode::Success,
Self::Malformed => PathPaymentStrictSendResultCode::Malformed,
Self::Underfunded => PathPaymentStrictSendResultCode::Underfunded,
Self::SrcNoTrust => PathPaymentStrictSendResultCode::SrcNoTrust,
Self::SrcNotAuthorized => PathPaymentStrictSendResultCode::SrcNotAuthorized,
Self::NoDestination => PathPaymentStrictSendResultCode::NoDestination,
Self::NoTrust => PathPaymentStrictSendResultCode::NoTrust,
Self::NotAuthorized => PathPaymentStrictSendResultCode::NotAuthorized,
Self::LineFull => PathPaymentStrictSendResultCode::LineFull,
Self::NoIssuer(_) => PathPaymentStrictSendResultCode::NoIssuer,
Self::TooFewOffers => PathPaymentStrictSendResultCode::TooFewOffers,
Self::OfferCrossSelf => PathPaymentStrictSendResultCode::OfferCrossSelf,
Self::UnderDestmin => PathPaymentStrictSendResultCode::UnderDestmin,
}
}
}
impl PathPaymentStrictSendResult {
#[must_use]
pub const fn const_xdr_len(&self) -> usize {
let mut empty: [u8; 0] = [];
let mut w = ConstWriter::new(&mut empty);
w.write_type_path_payment_strict_send_result(self);
w.len()
}
#[must_use]
pub const fn const_to_xdr<const N: usize>(&self) -> [u8; N] {
let mut buf = [0u8; N];
let mut w = ConstWriter::new(&mut buf);
w.write_type_path_payment_strict_send_result(self);
assert!(
w.len() == N,
"const_to_xdr: N does not equal the XDR-encoded length"
);
buf
}
}
impl ConstWriter<'_> {
pub const fn write_type_path_payment_strict_send_result(
&mut self,
v: &PathPaymentStrictSendResult,
) {
let d = v.discriminant();
self.write_type_path_payment_strict_send_result_code(&d);
#[allow(clippy::match_same_arms)]
match v {
PathPaymentStrictSendResult::Success(value) => {
self.write_type_path_payment_strict_send_result_success(value);
}
PathPaymentStrictSendResult::Malformed => {}
PathPaymentStrictSendResult::Underfunded => {}
PathPaymentStrictSendResult::SrcNoTrust => {}
PathPaymentStrictSendResult::SrcNotAuthorized => {}
PathPaymentStrictSendResult::NoDestination => {}
PathPaymentStrictSendResult::NoTrust => {}
PathPaymentStrictSendResult::NotAuthorized => {}
PathPaymentStrictSendResult::LineFull => {}
PathPaymentStrictSendResult::NoIssuer(value) => {
self.write_type_asset(value);
}
PathPaymentStrictSendResult::TooFewOffers => {}
PathPaymentStrictSendResult::OfferCrossSelf => {}
PathPaymentStrictSendResult::UnderDestmin => {}
}
}
}