BruteForce

Struct BruteForce 

Source
pub struct BruteForce<Insn, InputParameters, ReturnValue: Clone, TargetFunction: Callable<InputParameters, ReturnValue>, Searchable: Callable<InputParameters, ReturnValue> + BruteforceSearch<Insn>> {
    pub count: usize,
    /* private fields */
}
Expand description

Performs a brute force search over a given search space Searchable

Fields§

§count: usize

Keeps track of how many iterations the bruteforce search has been through.

Implementations§

Source§

impl<Insn, InputParameters: Copy + Vals, ReturnValue: Vals + PartialEq + Clone, TargetFunction: Callable<InputParameters, ReturnValue>, Searchable: Callable<InputParameters, ReturnValue> + BruteforceSearch<Insn> + Clone> BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>

Source

pub fn new( target_function: TargetFunction, initial_candidate: Searchable, ) -> Self

Constructs a new BruteForce

Source

pub fn candidate(&self) -> &Searchable

Returns the candidate currently under consideration

Source

pub fn step(&mut self) -> IterationResult

Advances the candidate to the next position in the search space

Source

pub fn test(&mut self) -> bool

Tests that the candidate matches the target function

Source

pub fn search(&mut self) -> Option<Searchable>

Returns the next function that matches the target function

Examples found in repository?
examples/ng.rs (line 21)
13fn main() {
14    let target_function = zero as fn(u8) -> RunResult<u8>;
15
16    // do a bruteforce search for Z80 machine code programs implementing the same function
17    let mut bruteforce = strop::mips::O32::default()
18        .trace()
19        .to_bruteforce(target_function);
20
21    let bf = bruteforce.search().unwrap();
22
23    println!("An equivalent subroutine we found by bruteforce search,");
24    println!("after {} iterations.", bruteforce.count);
25    bf.dasm();
26}

Trait Implementations§

Source§

impl<Insn: Clone, InputParameters: Clone, ReturnValue: Clone + Clone, TargetFunction: Clone + Callable<InputParameters, ReturnValue>, Searchable: Clone + Callable<InputParameters, ReturnValue> + BruteforceSearch<Insn>> Clone for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>

Source§

fn clone( &self, ) -> BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>

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

impl<Insn: Debug, InputParameters: Debug, ReturnValue: Debug + Clone, TargetFunction: Debug + Callable<InputParameters, ReturnValue>, Searchable: Debug + Callable<InputParameters, ReturnValue> + BruteforceSearch<Insn>> Debug for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> Freeze for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: Freeze, Searchable: Freeze,

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> RefUnwindSafe for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: RefUnwindSafe, Searchable: RefUnwindSafe, InputParameters: RefUnwindSafe, ReturnValue: RefUnwindSafe, Insn: RefUnwindSafe,

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> Send for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: Send, Searchable: Send, InputParameters: Send, ReturnValue: Send, Insn: Send,

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> Sync for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: Sync, Searchable: Sync, InputParameters: Sync, ReturnValue: Sync, Insn: Sync,

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> Unpin for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: Unpin, Searchable: Unpin, InputParameters: Unpin, ReturnValue: Unpin, Insn: Unpin,

§

impl<Insn, InputParameters, ReturnValue, TargetFunction, Searchable> UnwindSafe for BruteForce<Insn, InputParameters, ReturnValue, TargetFunction, Searchable>
where TargetFunction: UnwindSafe, Searchable: UnwindSafe, InputParameters: UnwindSafe, ReturnValue: UnwindSafe, Insn: UnwindSafe,

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> 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> ToTrace for T

Source§

fn trace(self) -> Trace<Self>
where Self: Sized + Clone + Disassemble,

Wraps an object up in a Trace, so that each mutation is printed to stdout.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V