pub enum RexValue {
Plain(Vec<u8>),
Encrypted(Vec<u8>),
}Expand description
Represents a value that can be either plain text or encrypted.
This enum is used to handle REX data that may contain sensitive information that needs to be encrypted when transmitted or stored, while also supporting plain text values for non-sensitive data.
Both variants accept JSON strings or byte arrays during deserialization. Serialization always outputs the canonical byte-array format.
§Variants
Plain(Vec<u8>)- A plain text value that is not encrypted. Accepts a JSON string (e.g.,{"Plain": "hello"}) or byte array.Encrypted(Vec<u8>)- Encrypted ciphertext. When passed as a JSON string, the value should be base64-encoded ciphertext for TEE decryption. No base64 validation is performed at deserialization time.
Variants§
Implementations§
Source§impl RexValue
impl RexValue
Sourcepub fn plain_string(s: impl Into<String>) -> Self
pub fn plain_string(s: impl Into<String>) -> Self
Create a plain value from a string (convenience method).
This is the preferred way to create an RexValue from string data
after the migration from string-based RexValue.
Sourcepub fn encrypted(ciphertext: Vec<u8>) -> Self
pub fn encrypted(ciphertext: Vec<u8>) -> Self
Create an encrypted value from raw ciphertext bytes.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Get the inner data as a string slice, if it’s valid UTF-8.
Returns Some(&str) if the data is valid UTF-8, None otherwise.
Only works on Plain variants; Encrypted always returns None.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Get the inner data as a byte slice.
Works on both Plain and Encrypted variants.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Returns true if this is an Encrypted variant.
Trait Implementations§
Source§impl BorshDeserialize for RexValue
impl BorshDeserialize for RexValue
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for RexValue
impl BorshSerialize for RexValue
Source§impl<'de> Deserialize<'de> for RexValue
impl<'de> Deserialize<'de> for RexValue
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>,
impl Eq for RexValue
impl StructuralPartialEq for RexValue
Auto Trait Implementations§
impl Freeze for RexValue
impl RefUnwindSafe for RexValue
impl Send for RexValue
impl Sync for RexValue
impl Unpin for RexValue
impl UnsafeUnpin for RexValue
impl UnwindSafe for RexValue
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.