Struct CilPrimitive

pub struct CilPrimitive {
    pub kind: CilPrimitiveKind,
    pub data: CilPrimitiveData,
}
Expand description

Represents all primitive types in CIL/.NET with optional data

Fields§

§kind: CilPrimitiveKind

The type of primitive

§data: CilPrimitiveData

The actual data (if available)

Implementations§

§

impl CilPrimitive

pub fn new(kind: CilPrimitiveKind) -> Self

Create a new primitive with the default value

§Arguments
  • kind - The type or primitive to create

pub fn with_data(kind: CilPrimitiveKind, data: CilPrimitiveData) -> Self

Create a primitive with specific data

§Arguments
  • kind - Set the kind of primitive
  • data - Set the data for the primitive

pub fn boolean(value: bool) -> Self

Create a boolean primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn char(value: char) -> Self

Create a character primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn i1(value: i8) -> Self

Create an i8 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn u1(value: u8) -> Self

Create a u8 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn i2(value: i16) -> Self

Create an i16 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn u2(value: u16) -> Self

Create a u16 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn i4(value: i32) -> Self

Create an i32 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn u4(value: u32) -> Self

Create a u32 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn i8(value: i64) -> Self

Create an i64 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn u8(value: u64) -> Self

Create a u64 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn r4(value: f32) -> Self

Create an f32 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn r8(value: f64) -> Self

Create an f64 primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn u(value: usize) -> Self

Create an usize primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn i(value: isize) -> Self

Create an isize primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn string(value: &str) -> Self

Create a string primitive

§Arguments
  • value - The initial value for the requested primitive

pub fn null() -> Self

Create a null primitive

pub fn token(&self) -> Token

Get the token for this primitive type

pub fn as_byte(&self) -> u8

Get the byte representation in type signatures (per ECMA-335 spec)

pub fn from_byte(byte: u8) -> Result<Self>

Try to parse a primitive type from a signature byte

§Arguments
  • byte - The kind byte to convert
§Errors

Returns TypeNotPrimitive if the byte does not represent a valid primitive type.

pub fn clr_full_name(&self) -> &'static str

Get the CLR full type name (with namespace)

pub fn namespace(&self) -> &'static str

Get the namespace of this type

pub fn name(&self) -> &'static str

Get the short name (without namespace)

pub fn to_flavor(&self) -> CilFlavor

Convert to CilFlavor

pub fn is_value_type(&self) -> bool

Is this a value type

pub fn is_reference_type(&self) -> bool

Is this a reference type

pub fn from_blob(p_type: u8, blob: &[u8]) -> Result<Self>

Parse a primitive value from a blob of data

§Arguments
  • p_type - The primitive byte to determine the kind of
  • blob - The data blob to parse for the value
§Errors

Returns TypeNotPrimitive if the primitive type is invalid. Returns OutOfBounds or other errors if the blob data is insufficient or invalid.

pub fn as_boolean(&self) -> Option<bool>

Try to get as boolean value

pub fn as_i32(&self) -> Option<i32>

Try to get as i32 value

pub fn as_i64(&self) -> Option<i64>

Try to get as i64 value

pub fn as_f64(&self) -> Option<f64>

Try to get as f64 value

pub fn as_string(&self) -> Option<String>

Try to get as string value

pub fn to_bytes(&self) -> Vec<u8>

Serialize this primitive to bytes

Trait Implementations§

§

impl Clone for CilPrimitive

§

fn clone(&self) -> CilPrimitive

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for CilPrimitive

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Display for CilPrimitive

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl From<&str> for CilPrimitive

§

fn from(value: &str) -> Self

Converts to this type from the input type.
§

impl From<CilPrimitive> for CilFlavor

§

fn from(primitive: CilPrimitive) -> Self

Converts to this type from the input type.
§

impl From<String> for CilPrimitive

§

fn from(value: String) -> Self

Converts to this type from the input type.
§

impl From<bool> for CilPrimitive

§

fn from(value: bool) -> Self

Converts to this type from the input type.
§

impl From<char> for CilPrimitive

§

fn from(value: char) -> Self

Converts to this type from the input type.
§

impl From<f32> for CilPrimitive

§

fn from(value: f32) -> Self

Converts to this type from the input type.
§

impl From<f64> for CilPrimitive

§

fn from(value: f64) -> Self

Converts to this type from the input type.
§

impl From<i16> for CilPrimitive

§

fn from(value: i16) -> Self

Converts to this type from the input type.
§

impl From<i32> for CilPrimitive

§

fn from(value: i32) -> Self

Converts to this type from the input type.
§

impl From<i64> for CilPrimitive

§

fn from(value: i64) -> Self

Converts to this type from the input type.
§

impl From<i8> for CilPrimitive

§

fn from(value: i8) -> Self

Converts to this type from the input type.
§

impl From<u16> for CilPrimitive

§

fn from(value: u16) -> Self

Converts to this type from the input type.
§

impl From<u32> for CilPrimitive

§

fn from(value: u32) -> Self

Converts to this type from the input type.
§

impl From<u64> for CilPrimitive

§

fn from(value: u64) -> Self

Converts to this type from the input type.
§

impl From<u8> for CilPrimitive

§

fn from(value: u8) -> Self

Converts to this type from the input type.
§

impl PartialEq for CilPrimitive

§

fn eq(&self, other: &CilPrimitive) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl TryFrom<CilFlavor> for CilPrimitive

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(flavor: CilFlavor) -> Result<Self>

Performs the conversion.
§

impl TryFrom<CilPrimitive> for String

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(value: CilPrimitive) -> Result<Self>

Performs the conversion.
§

impl TryFrom<CilPrimitive> for bool

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(value: CilPrimitive) -> Result<Self>

Performs the conversion.
§

impl TryFrom<CilPrimitive> for f64

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(value: CilPrimitive) -> Result<Self>

Performs the conversion.
§

impl TryFrom<CilPrimitive> for i32

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(value: CilPrimitive) -> Result<Self>

Performs the conversion.
§

impl TryFrom<CilPrimitive> for i64

§

type Error = Error

The type returned in the event of a conversion error.
§

fn try_from(value: CilPrimitive) -> Result<Self>

Performs the conversion.
§

impl StructuralPartialEq for CilPrimitive

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.