pub struct RustClr<'a> { /* private fields */ }Expand description
Represents a Rust interface to the Common Language Runtime (CLR).
§Example
use rustclr::{RustClr, RuntimeVersion};
use std::fs;
// Load a sample .NET assembly into a buffer
let buffer = fs::read("examples/sample.exe")?;
let mut clr = RustClr::new(&buffer)?
.with_runtime_version(RuntimeVersion::V4)
.with_domain("CustomDomain")
.with_args(vec!["arg1", "arg2"])
.with_output();
let output = clr.run()?;
println!("Output: {}", output);Implementations§
Source§impl<'a> RustClr<'a>
impl<'a> RustClr<'a>
Sourcepub fn new<T: Into<ClrSource<'a>>>(source: T) -> Result<Self>
pub fn new<T: Into<ClrSource<'a>>>(source: T) -> Result<Self>
Creates a new RustClr.
§Errors
Returned when the file cannot be read or when the buffer does not represent a valid .NET executable.
Sourcepub fn with_runtime_version(self, version: RuntimeVersion) -> Self
pub fn with_runtime_version(self, version: RuntimeVersion) -> Self
Sets the .NET runtime version to use.
Sourcepub fn with_domain(self, domain_name: &str) -> Self
pub fn with_domain(self, domain_name: &str) -> Self
Sets the application domain name.
Sourcepub fn with_args(self, args: Vec<&str>) -> Self
pub fn with_args(self, args: Vec<&str>) -> Self
Sets arguments to be passed to the assembly’s entry point.
Sourcepub fn with_output(self) -> Self
pub fn with_output(self) -> Self
Enables or disables output redirection.
Sourcepub fn with_patch_exit(self) -> Self
pub fn with_patch_exit(self) -> Self
Enables patching of the System.Environment.Exit method in mscorlib.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RustClr<'a>
impl<'a> RefUnwindSafe for RustClr<'a>
impl<'a> !Send for RustClr<'a>
impl<'a> !Sync for RustClr<'a>
impl<'a> Unpin for RustClr<'a>
impl<'a> UnwindSafe for RustClr<'a>
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