pub enum CIP25ChunkableString {
Single(CIP25String64),
Chunked(Vec<CIP25String64>),
}Expand description
A String that may or may not be chunked into 64-byte chunks to be able to conform to Cardano TX Metadata limitations. Unless you have good reasons, you should be using the From<&str> trait to construct this:
use cml_cip25::CIP25ChunkableString;
// automatically chunks this too long string into two chunks:
let chunkable_string = CIP25ChunkableString::from("this can be any length and will automatically be chunked into 64-byte pieces when/if needed");
match chunkable_string {
CIP25ChunkableString::Single(_) => panic!(),
CIP25ChunkableString::Chunked(chunks) => {
assert_eq!(chunks[0].to_str(), "this can be any length and will automatically be chunked into 64");
assert_eq!(chunks[1].to_str(), "-byte pieces when/if needed");
},
}Variants§
Single(CIP25String64)
Chunked(Vec<CIP25String64>)
Implementations§
Source§impl CIP25ChunkableString
impl CIP25ChunkableString
Sourcepub fn new_single(single: CIP25String64) -> Self
pub fn new_single(single: CIP25String64) -> Self
Construct from a single <=64 byte string chunk. If size is not known or for simplicity use From<&str> instead
Sourcepub fn new_chunked(chunked: Vec<CIP25String64>) -> Self
pub fn new_chunked(chunked: Vec<CIP25String64>) -> Self
Construct from an explicit list of chunks If size is not known or for simplicity use From<&str> instead
Trait Implementations§
Source§impl Clone for CIP25ChunkableString
impl Clone for CIP25ChunkableString
Source§fn clone(&self) -> CIP25ChunkableString
fn clone(&self) -> CIP25ChunkableString
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 CIP25ChunkableString
impl Debug for CIP25ChunkableString
Source§impl<'de> Deserialize<'de> for CIP25ChunkableString
impl<'de> Deserialize<'de> for CIP25ChunkableString
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Deserialize for CIP25ChunkableString
impl Deserialize for CIP25ChunkableString
fn deserialize<R: BufRead + Seek>( raw: &mut Deserializer<R>, ) -> Result<Self, DeserializeError>
Source§fn from_cbor_bytes(data: &[u8]) -> Result<Self, DeserializeError>where
Self: Sized,
fn from_cbor_bytes(data: &[u8]) -> Result<Self, DeserializeError>where
Self: Sized,
from-bytes using the exact CBOR format specified in the CDDL binary spec.
For hashes/addresses/etc this will include the CBOR bytes type/len/etc.
Source§impl From<&CIP25ChunkableString> for String
impl From<&CIP25ChunkableString> for String
Source§fn from(chunkable: &CIP25ChunkableString) -> Self
fn from(chunkable: &CIP25ChunkableString) -> Self
Converts to this type from the input type.
Source§impl From<&str> for CIP25ChunkableString
impl From<&str> for CIP25ChunkableString
Source§impl JsonSchema for CIP25ChunkableString
impl JsonSchema for CIP25ChunkableString
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§impl Serialize for CIP25ChunkableString
impl Serialize for CIP25ChunkableString
fn serialize<'se, W: Write>( &self, serializer: &'se mut Serializer<W>, ) -> Result<&'se mut Serializer<W>>
Auto Trait Implementations§
impl Freeze for CIP25ChunkableString
impl RefUnwindSafe for CIP25ChunkableString
impl Send for CIP25ChunkableString
impl Sync for CIP25ChunkableString
impl Unpin for CIP25ChunkableString
impl UnwindSafe for CIP25ChunkableString
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> FromBytes for Twhere
T: Deserialize,
impl<T> FromBytes for Twhere
T: Deserialize,
fn from_bytes(data: Vec<u8>) -> Result<T, DeserializeError>
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 more