use crate::_c;
mod control;
mod etxn;
mod float;
mod ledger;
mod otxn;
mod slot;
mod state;
mod sto;
mod trace;
mod util;
pub use control::*;
pub use etxn::*;
pub use float::*;
pub use ledger::*;
pub use otxn::*;
pub use slot::*;
pub use state::*;
pub use sto::*;
pub use trace::*;
pub use util::*;
pub const TF_CANONICAL: u32 = _c::tfCANONICAL;
pub const ACC_ID_LEN: usize = 20;
pub const CURRENCY_CODE_SIZE: usize = 20;
pub const LEDGER_HASH_LEN: usize = 32;
pub const KEYLET_LEN: usize = 34;
pub const STATE_KEY_LEN: usize = 32;
pub const NONCE_LEN: usize = 32;
pub const HASH_LEN: usize = 32;
pub const AMOUNT_LEN: usize = 48;
pub const EMIT_DETAILS_SIZE: usize = 105;
pub type Buffer<const T: usize> = [u8; T];
pub type AccountId = Buffer<ACC_ID_LEN>;
pub type Hash = Buffer<HASH_LEN>;
pub type Keylet = Buffer<KEYLET_LEN>;
pub type StateKey = Buffer<STATE_KEY_LEN>;
pub type Nonce = Buffer<NONCE_LEN>;
pub type Amount = Buffer<AMOUNT_LEN>;
pub type EmitDetails = Buffer<EMIT_DETAILS_SIZE>;
pub type CurrencyCode = Buffer<CURRENCY_CODE_SIZE>;
#[allow(missing_docs)]
#[derive(Clone, Copy)]
#[repr(u32)]
pub enum TxnType {
Payment = _c::ttPAYMENT,
EscrowCreate = 1,
EscrowFinish = 2,
AccountSet = 3,
EscrowCancel = 4,
RegularKeySet = 5,
OfferCreate = 7,
OfferCancel = 8,
TicketCreate = 10,
SignerListSet = 12,
PaychanCreate = 13,
PaychanFund = 14,
PaychanClaim = 15,
CheckCreate = 16,
CheckCash = 17,
CheckCancel = 18,
DepositPreauth = 19,
TrustSet = 20,
AccountDelete = 21,
HookSet = 22,
NFTokenMint = 25,
NFTokenBurn = 26,
NFTokenCreateOffer = 27,
NFTokenCancelOffer = 28,
NFTokenAcceptOffer = 29,
URITokenMint = 45,
URITokenBurn = 46,
URITokenBuy = 47,
URITokenCreateSellOffer = 48,
URITokenCancelSellOffer = 49,
Remit = 95,
GenesisMint = 96,
Import = 97,
ClaimReward = 98,
Invoke = 99,
Amendment = 100,
Fee = 101,
UnlModify = 102,
}
#[allow(missing_docs)]
#[derive(Clone, Copy)]
#[repr(u32)]
pub enum AccountType {
Account = _c::atACCOUNT,
Owner = _c::atOWNER,
Destination = _c::atDESTINATION,
Issuer = _c::atISSUER,
Authorize = _c::atAUTHORIZE,
Unauthorize = _c::atUNAUTHORIZE,
Target = _c::atTARGET,
RegularKey = _c::atREGULARKEY,
PseudoCallback = _c::atPSEUDOCALLBACK,
}
#[allow(missing_docs)]
#[derive(Clone, Copy)]
#[repr(u32)]
pub enum AmountType {
Amount = _c::amAMOUNT,
Balance = _c::amBALANCE,
LimitAmount = _c::amLIMITAMOUNT,
TakerPays = _c::amTAKERPAYS,
TakerGets = _c::amTAKERGETS,
LowLimit = _c::amLOWLIMIT,
HighLimit = _c::amHIGHLIMIT,
Fee = _c::amFEE,
SendMax = _c::amSENDMAX,
DeliverMin = _c::amDELIVERMIN,
MinimumOffer = _c::amMINIMUMOFFER,
RippleEscrow = _c::amRIPPLEESCROW,
DeliveredAmount = _c::amDELIVEREDAMOUNT,
}
#[allow(missing_docs)]
#[derive(Clone, Copy)]
pub enum KeyletType<'a> {
Hook(&'a [u8]),
HookState(&'a [u8], &'a [u8]),
Account(&'a [u8]),
Amendments,
Child(&'a [u8]),
Skip(Option<(u32, u32)>),
Fees,
NegativeUnl,
Line(&'a [u8], &'a [u8], &'a [u8]),
Offer(&'a [u8], u32),
Quality(&'a [u8], u32, u32),
EmittedDir,
Signers(&'a [u8]),
Check(&'a [u8], u32),
DepositPreauth(&'a [u8], &'a [u8]),
Unchecked(&'a [u8]),
OwnerDir(&'a [u8]),
Page(&'a [u8], u32, u32),
Escrow(&'a [u8], u32),
Paychan(&'a [u8], &'a [u8], u32),
Emitted(&'a [u8]),
NFTOffer(&'a [u8], u32),
HookDefinition(&'a [u8]),
HookStateDir(&'a [u8], &'a [u8]),
}
#[derive(Clone, Copy)]
pub enum FieldOrXrpAmount {
Field(FieldId),
NativeAmount,
NonNativeAmount,
}
#[derive(Clone, Copy)]
pub enum SlotTypeFlags {
Field,
NativeAmount,
}
#[allow(missing_docs)]
#[derive(Clone, Copy)]
#[repr(u32)]
pub enum FieldId {
CloseResolution = _c::sfCloseResolution,
Method = _c::sfMethod,
TransactionResult = _c::sfTransactionResult,
TickSize = _c::sfTickSize,
UNLModifyDisabling = _c::sfUNLModifyDisabling,
HookResult = _c::sfHookResult,
LedgerEntryType = _c::sfLedgerEntryType,
TransactionType = _c::sfTransactionType,
SignerWeight = _c::sfSignerWeight,
TransferFee = _c::sfTransferFee,
Version = _c::sfVersion,
HookStateChangeCount = _c::sfHookStateChangeCount,
HookEmitCount = _c::sfHookEmitCount,
HookExecutionIndex = _c::sfHookExecutionIndex,
HookApiVersion = _c::sfHookApiVersion,
NetworkID = _c::sfNetworkID,
Flags = _c::sfFlags,
SourceTag = _c::sfSourceTag,
Sequence = _c::sfSequence,
PreviousTxnLgrSeq = _c::sfPreviousTxnLgrSeq,
LedgerSequence = _c::sfLedgerSequence,
CloseTime = _c::sfCloseTime,
ParentCloseTime = _c::sfParentCloseTime,
SigningTime = _c::sfSigningTime,
Expiration = _c::sfExpiration,
TransferRate = _c::sfTransferRate,
WalletSize = _c::sfWalletSize,
OwnerCount = _c::sfOwnerCount,
DestinationTag = _c::sfDestinationTag,
HighQualityIn = _c::sfHighQualityIn,
HighQualityOut = _c::sfHighQualityOut,
LowQualityIn = _c::sfLowQualityIn,
LowQualityOut = _c::sfLowQualityOut,
QualityIn = _c::sfQualityIn,
QualityOut = _c::sfQualityOut,
StampEscrow = _c::sfStampEscrow,
BondAmount = _c::sfBondAmount,
LoadFee = _c::sfLoadFee,
OfferSequence = _c::sfOfferSequence,
FirstLedgerSequence = _c::sfFirstLedgerSequence,
LastLedgerSequence = _c::sfLastLedgerSequence,
TransactionIndex = _c::sfTransactionIndex,
OperationLimit = _c::sfOperationLimit,
ReferenceFeeUnits = _c::sfReferenceFeeUnits,
ReserveBase = _c::sfReserveBase,
ReserveIncrement = _c::sfReserveIncrement,
SetFlag = _c::sfSetFlag,
ClearFlag = _c::sfClearFlag,
SignerQuorum = _c::sfSignerQuorum,
CancelAfter = _c::sfCancelAfter,
FinishAfter = _c::sfFinishAfter,
SignerListID = _c::sfSignerListID,
SettleDelay = _c::sfSettleDelay,
TicketCount = _c::sfTicketCount,
TicketSequence = _c::sfTicketSequence,
NFTokenTaxon = _c::sfNFTokenTaxon,
MintedNFTokens = _c::sfMintedNFTokens,
BurnedNFTokens = _c::sfBurnedNFTokens,
HookStateCount = _c::sfHookStateCount,
EmitGeneration = _c::sfEmitGeneration,
LockCount = _c::sfLockCount,
FirstNFTokenSequence = _c::sfFirstNFTokenSequence,
XahauActivationLgrSeq = _c::sfXahauActivationLgrSeq,
ImportSequence = _c::sfImportSequence,
RewardTime = _c::sfRewardTime,
RewardLgrFirst = _c::sfRewardLgrFirst,
RewardLgrLast = _c::sfRewardLgrLast,
IndexNext = _c::sfIndexNext,
IndexPrevious = _c::sfIndexPrevious,
BookNode = _c::sfBookNode,
OwnerNode = _c::sfOwnerNode,
BaseFee = _c::sfBaseFee,
ExchangeRate = _c::sfExchangeRate,
LowNode = _c::sfLowNode,
HighNode = _c::sfHighNode,
DestinationNode = _c::sfDestinationNode,
Cookie = _c::sfCookie,
ServerVersion = _c::sfServerVersion,
NFTokenOfferNode = _c::sfNFTokenOfferNode,
EmitBurden = _c::sfEmitBurden,
HookInstructionCount = _c::sfHookInstructionCount,
HookReturnCode = _c::sfHookReturnCode,
ReferenceCount = _c::sfReferenceCount,
AccountIndex = _c::sfAccountIndex,
AccountCount = _c::sfAccountCount,
RewardAccumulator = _c::sfRewardAccumulator,
EmailHash = _c::sfEmailHash,
TakerPaysCurrency = _c::sfTakerPaysCurrency,
TakerPaysIssuer = _c::sfTakerPaysIssuer,
TakerGetsCurrency = _c::sfTakerGetsCurrency,
TakerGetsIssuer = _c::sfTakerGetsIssuer,
LedgerHash = _c::sfLedgerHash,
ParentHash = _c::sfParentHash,
TransactionHash = _c::sfTransactionHash,
AccountHash = _c::sfAccountHash,
PreviousTxnID = _c::sfPreviousTxnID,
LedgerIndex = _c::sfLedgerIndex,
WalletLocator = _c::sfWalletLocator,
RootIndex = _c::sfRootIndex,
AccountTxnID = _c::sfAccountTxnID,
NFTokenID = _c::sfNFTokenID,
EmitParentTxnID = _c::sfEmitParentTxnID,
EmitNonce = _c::sfEmitNonce,
EmitHookHash = _c::sfEmitHookHash,
BookDirectory = _c::sfBookDirectory,
InvoiceID = _c::sfInvoiceID,
Amendment = _c::sfAmendment,
HookOn = _c::sfHookOn,
Digest = _c::sfDigest,
Channel = _c::sfChannel,
ConsensusHash = _c::sfConsensusHash,
CheckID = _c::sfCheckID,
ValidatedHash = _c::sfValidatedHash,
PreviousPageMin = _c::sfPreviousPageMin,
NextPageMin = _c::sfNextPageMin,
NFTokenBuyOffer = _c::sfNFTokenBuyOffer,
NFTokenSellOffer = _c::sfNFTokenSellOffer,
HookStateKey = _c::sfHookStateKey,
HookHash = _c::sfHookHash,
HookNamespace = _c::sfHookNamespace,
HookSetTxnID = _c::sfHookSetTxnID,
OfferID = _c::sfOfferID,
EscrowID = _c::sfEscrowID,
URITokenID = _c::sfURITokenID,
GovernanceFlags = _c::sfGovernanceFlags,
GovernanceMarks = _c::sfGovernanceMarks,
EmittedTxnID = _c::sfEmittedTxnID,
Amount = _c::sfAmount,
Balance = _c::sfBalance,
LimitAmount = _c::sfLimitAmount,
TakerPays = _c::sfTakerPays,
TakerGets = _c::sfTakerGets,
LowLimit = _c::sfLowLimit,
HighLimit = _c::sfHighLimit,
Fee = _c::sfFee,
SendMax = _c::sfSendMax,
DeliverMin = _c::sfDeliverMin,
MinimumOffer = _c::sfMinimumOffer,
RippleEscrow = _c::sfRippleEscrow,
DeliveredAmount = _c::sfDeliveredAmount,
NFTokenBrokerFee = _c::sfNFTokenBrokerFee,
LockedBalance = _c::sfLockedBalance,
BaseFeeDrops = _c::sfBaseFeeDrops,
ReserveBaseDrops = _c::sfReserveBaseDrops,
ReserveIncrementDrops = _c::sfReserveIncrementDrops,
PublicKey = _c::sfPublicKey,
MessageKey = _c::sfMessageKey,
SigningPubKey = _c::sfSigningPubKey,
TxnSignature = _c::sfTxnSignature,
URI = _c::sfURI,
Signature = _c::sfSignature,
Domain = _c::sfDomain,
FundCode = _c::sfFundCode,
RemoveCode = _c::sfRemoveCode,
ExpireCode = _c::sfExpireCode,
CreateCode = _c::sfCreateCode,
MemoType = _c::sfMemoType,
MemoData = _c::sfMemoData,
MemoFormat = _c::sfMemoFormat,
Fulfillment = _c::sfFulfillment,
Condition = _c::sfCondition,
MasterSignature = _c::sfMasterSignature,
UNLModifyValidator = _c::sfUNLModifyValidator,
ValidatorToDisable = _c::sfValidatorToDisable,
ValidatorToReEnable = _c::sfValidatorToReEnable,
HookStateData = _c::sfHookStateData,
HookReturnString = _c::sfHookReturnString,
HookParameterName = _c::sfHookParameterName,
HookParameterValue = _c::sfHookParameterValue,
Blob = _c::sfBlob,
Account = _c::sfAccount,
Owner = _c::sfOwner,
Destination = _c::sfDestination,
Issuer = _c::sfIssuer,
Authorize = _c::sfAuthorize,
Unauthorize = _c::sfUnauthorize,
RegularKey = _c::sfRegularKey,
NFTokenMinter = _c::sfNFTokenMinter,
EmitCallback = _c::sfEmitCallback,
HookAccount = _c::sfHookAccount,
Inform = _c::sfInform,
Indexes = _c::sfIndexes,
Hashes = _c::sfHashes,
Amendments = _c::sfAmendments,
NFTokenOffers = _c::sfNFTokenOffers,
HookNamespaces = _c::sfHookNamespaces,
URITokenIDs = _c::sfURITokenIDs,
Paths = _c::sfPaths,
TransactionMetaData = _c::sfTransactionMetaData,
CreatedNode = _c::sfCreatedNode,
DeletedNode = _c::sfDeletedNode,
ModifiedNode = _c::sfModifiedNode,
PreviousFields = _c::sfPreviousFields,
FinalFields = _c::sfFinalFields,
NewFields = _c::sfNewFields,
TemplateEntry = _c::sfTemplateEntry,
Memo = _c::sfMemo,
SignerEntry = _c::sfSignerEntry,
EmitDetails = _c::sfEmitDetails,
Hook = _c::sfHook,
Signer = _c::sfSigner,
Majority = _c::sfMajority,
DisabledValidator = _c::sfDisabledValidator,
EmittedTxn = _c::sfEmittedTxn,
HookExecution = _c::sfHookExecution,
HookDefinition = _c::sfHookDefinition,
HookParameter = _c::sfHookParameter,
HookGrant = _c::sfHookGrant,
GenesisMint = _c::sfGenesisMint,
ActiveValidator = _c::sfActiveValidator,
ImportVLKey = _c::sfImportVLKey,
HookEmission = _c::sfHookEmission,
MintURIToken = _c::sfMintURIToken,
AmountEntry = _c::sfAmountEntry,
Signers = _c::sfSigners,
SignerEntries = _c::sfSignerEntries,
Template = _c::sfTemplate,
Necessary = _c::sfNecessary,
Sufficient = _c::sfSufficient,
AffectedNodes = _c::sfAffectedNodes,
Memos = _c::sfMemos,
NFTokens = _c::sfNFTokens,
Majorities = _c::sfMajorities,
DisabledValidators = _c::sfDisabledValidators,
HookExecutions = _c::sfHookExecutions,
HookParameters = _c::sfHookParameters,
HookGrants = _c::sfHookGrants,
GenesisMints = _c::sfGenesisMints,
ActiveValidators = _c::sfActiveValidators,
ImportVLKeys = _c::sfImportVLKeys,
HookEmissions = _c::sfHookEmissions,
Amounts = _c::sfAmounts,
}
#[derive(Clone, Copy)]
pub enum DataRepr {
AsUTF8 = 0,
AsHex = 1,
}
#[must_use]
pub enum Result<T> {
Ok(T),
Err(Error),
}
pub use self::Result::*;
#[allow(unused_attributes)]
#[must_use]
impl<T> Result<T> {
#[inline(always)]
pub fn expect(self, msg: &[u8]) -> T {
match self {
Err(e) => rollback(msg, e.code() as _),
Ok(val) => val,
}
}
#[inline(always)]
pub fn unwrap(self) -> T {
match self {
Err(e) => rollback(b"error", e.code() as _),
Ok(val) => val,
}
}
#[inline(always)]
pub unsafe fn unwrap_unchecked(self) -> T {
match self {
Ok(val) => val,
Err(_) => core::hint::unreachable_unchecked(),
}
}
#[must_use]
#[inline(always)]
pub const fn is_ok(&self) -> bool {
matches!(*self, Ok(_))
}
#[must_use]
#[inline(always)]
pub const fn is_err(&self) -> bool {
!self.is_ok()
}
}
#[derive(Clone, Copy)]
#[repr(i32)]
pub enum Error {
OutOfBounds = _c::OUT_OF_BOUNDS,
InternalError = _c::INTERNAL_ERROR,
TooBig = _c::TOO_BIG,
TooSmall = _c::TOO_SMALL,
DoesntExist = _c::DOESNT_EXIST,
NoFreeSlots = _c::NO_FREE_SLOTS,
InvalidArgument = _c::INVALID_ARGUMENT,
AlreadySet = _c::ALREADY_SET,
PrerequisiteNotMet = _c::PREREQUISITE_NOT_MET,
FeeTooLarge = _c::FEE_TOO_LARGE,
EmissionFailure = _c::EMISSION_FAILURE,
TooManyNonces = _c::TOO_MANY_NONCES,
TooManyEmittedTxn = _c::TOO_MANY_EMITTED_TXN,
NotImplemented = _c::NOT_IMPLEMENTED,
InvalidAccount = _c::INVALID_ACCOUNT,
GuardViolation = _c::GUARD_VIOLATION,
InvalidField = _c::INVALID_FIELD,
ParseError = _c::PARSE_ERROR,
RcRollback = _c::RC_ROLLBACK,
RcAccept = _c::RC_ACCEPT,
NoSuchKeylet = _c::NO_SUCH_KEYLET,
NotAnArray = _c::NOT_AN_ARRAY,
NotAnObject = _c::NOT_AN_OBJECT,
InvalidFloat = _c::INVALID_FLOAT,
DivisionByZero = _c::DIVISION_BY_ZERO,
MantissaOversized = _c::MANTISSA_OVERSIZED,
MantissaUndersized = _c::MANTISSA_UNDERSIZED,
ExponentOversized = _c::EXPONENT_OVERSIZED,
ExponentUndersized = _c::EXPONENT_UNDERSIZED,
XflOverflow = _c::XFL_OVERFLOW,
NotIouAmount = _c::NOT_IOU_AMOUNT,
NotAnAmount = _c::NOT_AN_AMOUNT,
CantReturnNegative = _c::CANT_RETURN_NEGATIVE,
NotAuthorized = _c::NOT_AUTHORIZED,
PreviousFailurePreventsRetry = _c::PREVIOUS_FAILURE_PREVENTS_RETRY,
TooManyParams = _c::TOO_MANY_PARAMS,
InvalidTxn = _c::INVALID_TXN,
ReserveInssuficient = _c::RESERVE_INSUFFICIENT,
ComplexNotSupported = _c::COMPLEX_NOT_SUPPORTED,
DoesNotMatch = _c::DOES_NOT_MATCH,
InvalidKey = _c::INVALID_KEY,
NotAString = _c::NOT_A_STRING,
MemOverlap = _c::MEM_OVERLAP,
TooManyStateModifications = _c::TOO_MANY_STATE_MODIFICATIONS,
TooManyNamespaces = _c::TOO_MANY_NAMESPACES,
}
impl Error {
#[inline(always)]
fn from_code(code: i32) -> Self {
unsafe { core::mem::transmute(code) }
}
#[inline(always)]
pub fn code(self) -> i32 {
self as _
}
}
type Api1ArgsU32 = unsafe extern "C" fn(u32) -> i64;
type Api2ArgsU32 = unsafe extern "C" fn(u32, u32) -> i64;
type Api3ArgsU32 = unsafe extern "C" fn(u32, u32, u32) -> i64;
type Api4ArgsU32 = unsafe extern "C" fn(u32, u32, u32, u32) -> i64;
type Api6ArgsU32 = unsafe extern "C" fn(u32, u32, u32, u32, u32, u32) -> i64;
type BufWriter = Api2ArgsU32;
type BufReader = Api2ArgsU32;
type Buf2Reader = Api4ArgsU32;
type BufWriterReader = Api4ArgsU32;
type Buf3Reader = Api6ArgsU32;
type BufWriter1Arg = Api3ArgsU32;
#[inline(always)]
fn api_1arg_call(arg: u32, fun: Api1ArgsU32) -> Result<i64> {
let res = unsafe { fun(arg) };
result_i64(res)
}
#[inline(always)]
fn api_3arg_call(arg_1: u32, arg_2: u32, arg_3: u32, fun: Api3ArgsU32) -> Result<i64> {
let res = unsafe { fun(arg_1, arg_2, arg_3) };
result_i64(res)
}
#[inline(always)]
fn buf_write(buf_write: &mut [u8], fun: BufWriter) -> Result<i64> {
let res = unsafe { fun(buf_write.as_mut_ptr() as u32, buf_write.len() as u32) };
result_i64(res)
}
#[inline(always)]
fn buf_write_1arg(buf_write: &mut [u8], arg: u32, fun: BufWriter1Arg) -> Result<i64> {
let res = unsafe { fun(buf_write.as_mut_ptr() as u32, buf_write.len() as u32, arg) };
result_i64(res)
}
#[inline(always)]
fn buf_read(buf: &[u8], fun: BufReader) -> Result<i64> {
let res = unsafe { fun(buf.as_ptr() as u32, buf.len() as u32) };
result_i64(res)
}
#[inline(always)]
fn buf_2read(buf_1: &[u8], buf_2: &[u8], fun: Buf2Reader) -> Result<i64> {
let res = unsafe {
fun(
buf_1.as_ptr() as u32,
buf_1.len() as u32,
buf_2.as_ptr() as u32,
buf_2.len() as u32,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_write_read(buf_write: &mut [u8], buf_read: &[u8], fun: BufWriterReader) -> Result<i64> {
let res = unsafe {
fun(
buf_write.as_mut_ptr() as u32,
buf_write.len() as u32,
buf_read.as_ptr() as u32,
buf_read.len() as u32,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_3_read(
buf_read_1: &[u8],
buf_read_2: &[u8],
buf_read_3: &[u8],
fun: Buf3Reader,
) -> Result<i64> {
let res = unsafe {
fun(
buf_read_1.as_ptr() as u32,
buf_read_1.len() as u32,
buf_read_2.as_ptr() as u32,
buf_read_2.len() as u32,
buf_read_3.as_ptr() as u32,
buf_read_3.len() as u32,
)
};
result_i64(res)
}
#[inline(always)]
fn range_from_location(location: i64) -> core::ops::Range<usize> {
let offset: i32 = (location >> 32) as _;
let lenght: i32 = (location & 0xFFFFFFFF) as _;
core::ops::Range {
start: offset as _,
end: (offset + lenght) as _,
}
}
#[inline(always)]
fn all_zeroes(buf_write: &mut [u8], keylet_type_c: u32) -> Result<i64> {
let res = unsafe {
_c::util_keylet(
buf_write.as_mut_ptr() as _,
buf_write.len() as _,
keylet_type_c,
0,
0,
0,
0,
0,
0,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_read_and_zeroes(buf_write: &mut [u8], buf_read: &[u8], keylet_type_c: u32) -> Result<i64> {
let res = unsafe {
_c::util_keylet(
buf_write.as_mut_ptr() as _,
buf_write.len() as _,
keylet_type_c,
buf_read.as_ptr() as _,
buf_read.len() as _,
0,
0,
0,
0,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_read_and_1_arg(
buf_write: &mut [u8],
buf_read: &[u8],
arg: u32,
keylet_type_c: u32,
) -> Result<i64> {
let res = unsafe {
_c::util_keylet(
buf_write.as_mut_ptr() as _,
buf_write.len() as _,
keylet_type_c,
buf_read.as_ptr() as _,
buf_read.len() as _,
arg,
0,
0,
0,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_read_and_2_args(
buf_write: &mut [u8],
buf_read: &[u8],
arg_1: u32,
arg_2: u32,
keylet_type_c: u32,
) -> Result<i64> {
let res = unsafe {
_c::util_keylet(
buf_write.as_mut_ptr() as _,
buf_write.len() as _,
keylet_type_c,
buf_read.as_ptr() as _,
buf_read.len() as _,
arg_1,
arg_2,
0,
0,
)
};
result_i64(res)
}
#[inline(always)]
fn buf_2_read_and_zeroes(
buf_write: &mut [u8],
buf_1_read: &[u8],
buf_2_read: &[u8],
keylet_type_c: u32,
) -> Result<i64> {
let res = unsafe {
_c::util_keylet(
buf_write.as_mut_ptr() as _,
buf_write.len() as _,
keylet_type_c,
buf_1_read.as_ptr() as _,
buf_1_read.len() as _,
buf_2_read.as_ptr() as _,
buf_2_read.len() as _,
0,
0,
)
};
result_i64(res)
}
#[inline(always)]
fn result_i64(res: i64) -> Result<i64> {
match res {
res if res >= 0 => Ok(res as _),
_ => Err(Error::from_code(res as _)),
}
}
#[inline(always)]
fn result_xfl(res: i64) -> Result<XFL> {
match res {
res if res >= 0 => Ok(XFL(res)),
_ => Err(Error::from_code(res as _)),
}
}