pub struct TransactionCodec;Expand description
Transaction encoding utilities
Implementations§
Source§impl TransactionCodec
impl TransactionCodec
Sourcepub fn encode_envelope(
envelope: &TransactionEnvelope,
) -> Result<Vec<u8>, EncodingError>
pub fn encode_envelope( envelope: &TransactionEnvelope, ) -> Result<Vec<u8>, EncodingError>
Encode transaction envelope to binary format Matches TS: Transaction.marshalBinary()
Sourcepub fn decode_envelope(
data: &[u8],
) -> Result<TransactionEnvelope, DecodingError>
pub fn decode_envelope( data: &[u8], ) -> Result<TransactionEnvelope, DecodingError>
Decode transaction envelope from binary format Matches TS: Transaction.unmarshalBinary()
Sourcepub fn encode_header(
header: &TransactionHeader,
) -> Result<Vec<u8>, EncodingError>
pub fn encode_header( header: &TransactionHeader, ) -> Result<Vec<u8>, EncodingError>
Encode transaction header Matches TS: TransactionHeader.marshalBinary()
Sourcepub fn decode_header(data: &[u8]) -> Result<TransactionHeader, DecodingError>
pub fn decode_header(data: &[u8]) -> Result<TransactionHeader, DecodingError>
Decode transaction header Matches TS: TransactionHeader.unmarshalBinary()
Sourcepub fn encode_signature(
signature: &TransactionSignature,
) -> Result<Vec<u8>, EncodingError>
pub fn encode_signature( signature: &TransactionSignature, ) -> Result<Vec<u8>, EncodingError>
Encode transaction signature Matches TS: TransactionSignature.marshalBinary()
Sourcepub fn decode_signature(
data: &[u8],
) -> Result<TransactionSignature, DecodingError>
pub fn decode_signature( data: &[u8], ) -> Result<TransactionSignature, DecodingError>
Decode transaction signature Matches TS: TransactionSignature.unmarshalBinary()
Sourcepub fn encode_key_page(
key_page: &TransactionKeyPage,
) -> Result<Vec<u8>, EncodingError>
pub fn encode_key_page( key_page: &TransactionKeyPage, ) -> Result<Vec<u8>, EncodingError>
Encode key page information
Sourcepub fn decode_key_page(data: &[u8]) -> Result<TransactionKeyPage, DecodingError>
pub fn decode_key_page(data: &[u8]) -> Result<TransactionKeyPage, DecodingError>
Decode key page information
Sourcepub fn get_transaction_hash(
envelope: &TransactionEnvelope,
) -> Result<[u8; 32], EncodingError>
pub fn get_transaction_hash( envelope: &TransactionEnvelope, ) -> Result<[u8; 32], EncodingError>
Get transaction hash for signing Matches TS: Transaction.getHash()
Sourcepub fn create_envelope(
principal: String,
body: Value,
timestamp: Option<u64>,
) -> TransactionEnvelope
pub fn create_envelope( principal: String, body: Value, timestamp: Option<u64>, ) -> TransactionEnvelope
Create transaction envelope with header and body
Sourcepub fn add_signature(
envelope: &mut TransactionEnvelope,
signature: Vec<u8>,
signer: String,
public_key: Option<Vec<u8>>,
)
pub fn add_signature( envelope: &mut TransactionEnvelope, signature: Vec<u8>, signer: String, public_key: Option<Vec<u8>>, )
Add signature to transaction envelope
Sourcepub fn validate_envelope(envelope: &TransactionEnvelope) -> Result<(), String>
pub fn validate_envelope(envelope: &TransactionEnvelope) -> Result<(), String>
Validate transaction envelope structure
Trait Implementations§
Source§impl Clone for TransactionCodec
impl Clone for TransactionCodec
Source§fn clone(&self) -> TransactionCodec
fn clone(&self) -> TransactionCodec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TransactionCodec
impl Debug for TransactionCodec
impl Copy for TransactionCodec
Auto Trait Implementations§
impl Freeze for TransactionCodec
impl RefUnwindSafe for TransactionCodec
impl Send for TransactionCodec
impl Sync for TransactionCodec
impl Unpin for TransactionCodec
impl UnwindSafe for TransactionCodec
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
Mutably borrows from an owned value. Read more