pub struct MethodDescriptor {
pub params: Vec<TypeDescriptor>,
pub return_type: Option<TypeDescriptor>,
}
Fields§
§params: Vec<TypeDescriptor>
The parameter types of the method.
§Examples
use jbcrs::{Type, MethodDescriptor};
let desc: MethodDescriptor = "(Z)V".parse().unwrap();
assert_eq!(Type::Boolean, desc.params[0].base_type);
return_type: Option<TypeDescriptor>
The return type of the method. None indicates ‘void’
§Examples
use jbcrs::{Type, MethodDescriptor};
let desc: MethodDescriptor = "()I".parse().unwrap();
assert_eq!(Type::Int, desc.return_type.unwrap().base_type);
Implementations§
Source§impl MethodDescriptor
impl MethodDescriptor
pub fn new( params: Vec<TypeDescriptor>, return_type: Option<TypeDescriptor>, ) -> MethodDescriptor
Trait Implementations§
Source§impl Debug for MethodDescriptor
impl Debug for MethodDescriptor
Source§impl Display for MethodDescriptor
impl Display for MethodDescriptor
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats this descriptor
§Examples
use jbcrs::{Type, MethodDescriptor};
let mut desc: MethodDescriptor = "(Ljava/lang/String;)I".parse().unwrap();
desc.return_type.as_mut().unwrap().base_type = Type::Long;
assert_eq!("(Ljava/lang/String;)J", desc.to_string());
desc.params[0].base_type = Type::Reference("java/lang/Double".to_owned());
assert_eq!("(Ljava/lang/Double;)J", desc.to_string());
Source§impl FromStr for MethodDescriptor
impl FromStr for MethodDescriptor
Source§fn from_str(desc: &str) -> Result<MethodDescriptor>
fn from_str(desc: &str) -> Result<MethodDescriptor>
Parses a string and returns a MethodDescriptor if it succeeded.
§Examples
use jbcrs::{Type, TypeDescriptor, MethodDescriptor};
let desc: MethodDescriptor = "([[DLjava/lang/Integer;)V".parse().unwrap();
assert_eq!(desc, MethodDescriptor {
params: vec![
TypeDescriptor {
dimensions: 2,
base_type: Type::Double,
},
TypeDescriptor {
dimensions: 0,
base_type: Type::Reference("java/lang/Integer".to_owned()),
},
],
return_type: None,
});
Source§impl PartialEq for MethodDescriptor
impl PartialEq for MethodDescriptor
impl Eq for MethodDescriptor
impl StructuralPartialEq for MethodDescriptor
Auto Trait Implementations§
impl Freeze for MethodDescriptor
impl RefUnwindSafe for MethodDescriptor
impl Send for MethodDescriptor
impl Sync for MethodDescriptor
impl Unpin for MethodDescriptor
impl UnwindSafe for MethodDescriptor
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