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],
/* private fields */
}Expand description
Similar to OwnedTransaction, but doesn’t require alloc or data ownership.
Can be created with Transaction::try_from_bytes() or borrowed from
OwnedTransaction::transaction().
Fields§
§header: &'a TransactionHeaderTransaction 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 don’t need to be specified (see Transaction::read_slots()).
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.
The layout is following data structures concatenated as bytes (they are carefully picked to ensure alignment):
TransactionHeaderSerializedTransactionLengths(with values set to correspond to below contents)- All read
TransactionSlot - All write
TransactionSlot - Payload as
u128s - Seal as
u8s
Payload and seal lengths in SerializedTransactionLengths are in bytes.
Returns an instance and remaining bytes on success.
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) -> impl Deref<Target = TransactionHash> + Send + Sync
pub fn hash(&self) -> impl Deref<Target = TransactionHash> + Send + Sync
Compute transaction hash.
Note that this method hashes the whole serialized transaction. The result is then cached if
alloc feature is enabled or when compiled for OS target that is not none.
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§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<(), OwnedLeafShardBodyError>
fn write_into( &self, buffer: &mut OwnedAlignedBuffer, ) -> Result<(), OwnedLeafShardBodyError>
Auto Trait Implementations§
impl<'a> !Freeze for Transaction<'a>
impl<'a> Forget 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> UnsafeUnpin 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