Struct jbcrs::TypeDescriptor [] [src]

pub struct TypeDescriptor {
    pub dimensions: u8,
    pub base_type: Type,
}

A TypeDescriptor is either a field descriptor, a single type (parameter or return type) of a method, or an element value of an annotation. In the JVM Specification FieldDescriptor is used as a name. Maybe using that one would be better, but I am too lazy to refactor now.

Fields

The dimensions of the type

Examples

use jbcrs::TypeDescriptor;
let desc: TypeDescriptor = "[[I".parse().unwrap();
assert_eq!(desc.dimensions, 2);

The base type

Examples

use jbcrs::{Type, TypeDescriptor};

let short_desc: TypeDescriptor = "S".parse().unwrap();
assert_eq!(short_desc.base_type, Type::Short);

let string_desc: TypeDescriptor = "[Ljava/lang/String;".parse().unwrap();
assert_eq!(
    string_desc.base_type,
    Type::Reference("java/lang/String".to_owned())
);

Methods

impl TypeDescriptor
[src]

[src]

Trait Implementations

impl Eq for TypeDescriptor
[src]

impl PartialEq for TypeDescriptor
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Debug for TypeDescriptor
[src]

[src]

Formats the value using the given formatter.

impl FromStr for TypeDescriptor
[src]

The associated error which can be returned from parsing.

[src]

Parses a string and returns a TypeDescriptor if it succeeded.

Examples

use jbcrs::{Type, TypeDescriptor};

let desc: TypeDescriptor = "[[[D".parse().unwrap();
assert_eq!(desc, TypeDescriptor { dimensions: 3, base_type: Type::Double });

impl Display for TypeDescriptor
[src]

[src]

Formats this descriptor

Examples

use jbcrs::{Type, TypeDescriptor};

let mut desc: TypeDescriptor = "[[Ljava/lang/String;".parse().unwrap();
desc.base_type = Type::Float;
assert_eq!("[[F", desc.to_string());

desc.base_type = Type::Reference("java/lang/Float".to_owned());
assert_eq!("[[Ljava/lang/Float;", desc.to_string());