pub struct Transaction<'a> {
pub header: &'a TransactionHeader,
pub read_slots: &'a [TransactionSlot],
pub write_slots: &'a [TransactionSlot],
pub payload: &'a [u128],
pub seal: &'a [u8],
}
Expand description
Similar to Transaction
, but doesn’t require allow
or data ownership.
Can be created with Transaction::as_ref()
call.
Fields§
§header: &'a TransactionHeader
Transaction header
read_slots: &'a [TransactionSlot]
Slots in the form of TransactionSlot
that may be read during transaction processing.
These are the only slots that can be used in authorization code.
The code slot of the contract that is being executed and balance of native token are
implicitly included and doesn’t need to be specified (see Transaction::read_slots()
.
Also slots that may also be written to do not need to be repeated in the read slots.
write_slots: &'a [TransactionSlot]
Slots in the form of TransactionSlot
that may be written during transaction processing
payload: &'a [u128]
Transaction payload
seal: &'a [u8]
Transaction seal
Implementations§
Source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub fn try_from_bytes(bytes: &'a [u8]) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes(bytes: &'a [u8]) -> Option<(Self, &'a [u8])>
Create an instance from provided correctly aligned bytes.
bytes
should be 16-bytes aligned.
See Self::from_bytes_unchecked()
for layout details.
Returns an instance and remaining bytes on success.
Sourcepub unsafe fn from_bytes_unchecked(bytes: &'a [u8]) -> Transaction<'a>
pub unsafe fn from_bytes_unchecked(bytes: &'a [u8]) -> Transaction<'a>
Create an instance from provided bytes without performing any checks for size or alignment.
The internal layout of the owned transaction is following data structures concatenated as bytes (they are carefully picked to ensure alignment):
TransactionHeader
SerializedTransactionLengths
(with values set to correspond to below contents)- All read
TransactionSlot
- All write
TransactionSlot
- Payload as
u128
s - Seal as
u8
s
§Safety
Caller must ensure provided bytes are 16-bytes aligned and of sufficient length. Extra bytes beyond necessary are silently ignored if provided.
Sourcepub fn to_owned(self) -> Result<OwnedTransaction, OwnedTransactionError>
pub fn to_owned(self) -> Result<OwnedTransaction, OwnedTransactionError>
Create an owned version of this transaction
Sourcepub const fn encoded_size(&self) -> usize
pub const fn encoded_size(&self) -> usize
Size of the encoded transaction in bytes
Sourcepub fn hash(&self) -> TransactionHash
pub fn hash(&self) -> TransactionHash
Compute transaction hash.
Note: this computes transaction hash on every call, so worth caching if it is expected to be called often.
Sourcepub fn read_slots(&self) -> impl Iterator<Item = TransactionSlot>
pub fn read_slots(&self) -> impl Iterator<Item = TransactionSlot>
Read slots touched by the transaction.
In contrast to read_slots
property, this includes implicitly used slots.
Sourcepub fn slots(&self) -> impl Iterator<Item = TransactionSlot>
pub fn slots(&self) -> impl Iterator<Item = TransactionSlot>
All slots touched by the transaction.
In contrast to read_slots
and write_slots
properties, this includes implicitly used
slots.
Trait Implementations§
Source§impl<'a> Clone for Transaction<'a>
impl<'a> Clone for Transaction<'a>
Source§fn clone(&self) -> Transaction<'a>
fn clone(&self) -> Transaction<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for Transaction<'a>
impl<'a> Debug for Transaction<'a>
Source§impl WritableBodyTransaction for Transaction<'_>
impl WritableBodyTransaction for Transaction<'_>
Source§fn write_into(
&self,
buffer: &mut OwnedAlignedBuffer,
) -> Result<(), OwnedTransactionError>
fn write_into( &self, buffer: &mut OwnedAlignedBuffer, ) -> Result<(), OwnedTransactionError>
impl<'a> Copy for Transaction<'a>
Auto Trait Implementations§
impl<'a> Freeze for Transaction<'a>
impl<'a> RefUnwindSafe for Transaction<'a>
impl<'a> Send for Transaction<'a>
impl<'a> Sync for Transaction<'a>
impl<'a> Unpin for Transaction<'a>
impl<'a> UnwindSafe for Transaction<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more