pub struct PlutusData(/* private fields */);
Implementations§
Source§impl PlutusData
impl PlutusData
Sourcepub fn to_cardano_node_format(&self) -> Self
pub fn to_cardano_node_format(&self) -> Self
- Convert to a Datum that will serialize equivalent to cardano-node’s format
- Please VERY STRONGLY consider using PlutusData::from_cbor_bytes() instead wherever possible.
- You should try to never rely on a tool encoding CBOR a certain way as there are many possible,
- and just because it matches with a specific datum, doesn’t mean that a different datum won’t differ.
- This is critical as that means the datum hash won’t match.
- After creation a datum (or other hashable CBOR object) should only be treated as raw CBOR bytes,
- or through a type that respects its specific CBOR format e.g. CML’s PlutusData::from_cbor_bytes()
- This function is just here in case there’s no possible way at all to create from CBOR bytes and
- thus cold only be constructed manually and then had this function called on it.
- This is also the format that CSL and Lucid use
Source§impl PlutusData
impl PlutusData
Sourcepub fn to_cbor_bytes(&self) -> Vec<u8> ⓘ
pub fn to_cbor_bytes(&self) -> Vec<u8> ⓘ
- Serialize this type to CBOR bytes
- This type type supports encoding preservation so this will preserve round-trip CBOR formats.
- If created from scratch the CBOR will be canonical.
Sourcepub fn to_canonical_cbor_bytes(&self) -> Vec<u8> ⓘ
pub fn to_canonical_cbor_bytes(&self) -> Vec<u8> ⓘ
- Serialize this type to CBOR bytes using canonical CBOR encodings
Sourcepub fn from_cbor_bytes(cbor_bytes: &[u8]) -> Result<PlutusData, JsError>
pub fn from_cbor_bytes(cbor_bytes: &[u8]) -> Result<PlutusData, JsError>
- Create this type from CBOR bytes
Sourcepub fn to_cbor_hex(&self) -> String
pub fn to_cbor_hex(&self) -> String
- Serialize this type to CBOR bytes encoded as a hex string (useful for working with CIP30).
- This type type supports encoding preservation so this will preserve round-trip CBOR formats.
- If created from scratch the CBOR will be canonical.
Sourcepub fn to_canonical_cbor_hex(&self) -> String
pub fn to_canonical_cbor_hex(&self) -> String
- Serialize this type to CBOR bytes using canonical CBOR encodings as hex bytes
Sourcepub fn from_cbor_hex(cbor_bytes: &str) -> Result<PlutusData, JsError>
pub fn from_cbor_hex(cbor_bytes: &str) -> Result<PlutusData, JsError>
- Create this type from the CBOR bytes encoded as a hex string.
- This is useful for interfacing with CIP30
Source§impl PlutusData
impl PlutusData
Source§impl PlutusData
impl PlutusData
pub fn new_constr_plutus_data(constr_plutus_data: &ConstrPlutusData) -> Self
pub fn new_map(map: &PlutusMap) -> Self
pub fn new_list(list: &PlutusDataList) -> Self
pub fn new_integer(big_int: &BigInteger) -> Self
pub fn new_bytes(bytes: Vec<u8>) -> Self
pub fn kind(&self) -> PlutusDataKind
pub fn as_constr_plutus_data(&self) -> Option<ConstrPlutusData>
pub fn as_map(&self) -> Option<PlutusMap>
pub fn as_list(&self) -> Option<PlutusDataList>
pub fn as_integer(&self) -> Option<BigInteger>
pub fn as_bytes(&self) -> Option<Vec<u8>>
Trait Implementations§
Source§impl AsRef<PlutusData> for PlutusData
impl AsRef<PlutusData> for PlutusData
Source§fn as_ref(&self) -> &PlutusData
fn as_ref(&self) -> &PlutusData
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Clone for PlutusData
impl Clone for PlutusData
Source§fn clone(&self) -> PlutusData
fn clone(&self) -> PlutusData
Returns a copy 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 PlutusData
impl Debug for PlutusData
Source§impl From<PlutusData> for JsValue
impl From<PlutusData> for JsValue
Source§fn from(value: PlutusData) -> Self
fn from(value: PlutusData) -> Self
Converts to this type from the input type.
Source§impl From<PlutusData> for PlutusData
impl From<PlutusData> for PlutusData
Source§fn from(native: PlutusData) -> Self
fn from(native: PlutusData) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for PlutusData
impl FromWasmAbi for PlutusData
Source§impl Into<PlutusData> for PlutusData
impl Into<PlutusData> for PlutusData
Source§fn into(self) -> PlutusData
fn into(self) -> PlutusData
Converts this type into the (usually inferred) input type.
Source§impl IntoWasmAbi for PlutusData
impl IntoWasmAbi for PlutusData
Source§impl LongRefFromWasmAbi for PlutusData
impl LongRefFromWasmAbi for PlutusData
Source§impl OptionFromWasmAbi for PlutusData
impl OptionFromWasmAbi for PlutusData
Source§impl OptionIntoWasmAbi for PlutusData
impl OptionIntoWasmAbi for PlutusData
Source§impl RefFromWasmAbi for PlutusData
impl RefFromWasmAbi for PlutusData
Source§type Anchor = RcRef<PlutusData>
type Anchor = RcRef<PlutusData>
The type that holds the reference to
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for PlutusData
impl RefMutFromWasmAbi for PlutusData
Source§impl TryFromJsValue for PlutusData
impl TryFromJsValue for PlutusData
Source§impl VectorFromWasmAbi for PlutusData
impl VectorFromWasmAbi for PlutusData
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[PlutusData]>
Source§impl VectorIntoJsValue for PlutusData
impl VectorIntoJsValue for PlutusData
fn vector_into_jsvalue(vector: Box<[PlutusData]>) -> JsValue
Source§impl VectorIntoWasmAbi for PlutusData
impl VectorIntoWasmAbi for PlutusData
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[PlutusData]>) -> Self::Abi
Source§impl WasmDescribeVector for PlutusData
impl WasmDescribeVector for PlutusData
impl SupportsConstructor for PlutusData
impl SupportsInstanceProperty for PlutusData
impl SupportsStaticProperty for PlutusData
Auto Trait Implementations§
impl Freeze for PlutusData
impl RefUnwindSafe for PlutusData
impl Send for PlutusData
impl Sync for PlutusData
impl Unpin for PlutusData
impl UnwindSafe for PlutusData
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
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>
Converts
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>
Converts
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 moreSource§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.