bytesinput to_file raw
This commit is contained in:
parent
7b772fedc5
commit
3124d03665
@ -84,8 +84,12 @@ where
|
||||
time,
|
||||
executions,
|
||||
} => {
|
||||
stats.client_stats_mut_for(0).update_corpus_size(*corpus_size as u64);
|
||||
stats.client_stats_mut_for(0).update_executions(*executions as u64, *time);
|
||||
stats
|
||||
.client_stats_mut_for(0)
|
||||
.update_corpus_size(*corpus_size as u64);
|
||||
stats
|
||||
.client_stats_mut_for(0)
|
||||
.update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
@ -95,12 +99,16 @@ where
|
||||
phantom: _,
|
||||
} => {
|
||||
// TODO: The stats buffer should be added on client add.
|
||||
stats.client_stats_mut_for(0).update_executions(*executions as u64, *time);
|
||||
stats
|
||||
.client_stats_mut_for(0)
|
||||
.update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
Event::Objective { objective_size } => {
|
||||
stats.client_stats_mut_for(0).update_objective_size(*objective_size as u64);
|
||||
stats
|
||||
.client_stats_mut_for(0)
|
||||
.update_objective_size(*objective_size as u64);
|
||||
stats.display(event.name().to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
|
@ -4,8 +4,17 @@
|
||||
use alloc::{borrow::ToOwned, rc::Rc, vec::Vec};
|
||||
use core::{cell::RefCell, convert::From};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "std")]
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use crate::inputs::{HasBytesVec, HasLen, HasTargetBytes, Input, TargetBytes};
|
||||
use crate::{
|
||||
inputs::{HasBytesVec, HasLen, HasTargetBytes, Input, TargetBytes},
|
||||
Error,
|
||||
};
|
||||
|
||||
/// A bytes input is the basic input
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
|
||||
@ -14,7 +23,30 @@ pub struct BytesInput {
|
||||
bytes: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Input for BytesInput {}
|
||||
impl Input for BytesInput {
|
||||
#[cfg(feature = "std")]
|
||||
/// Write this input to the file
|
||||
fn to_file<P>(&self, path: P) -> Result<(), Error>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let mut file = File::create(path)?;
|
||||
file.write_all(&self.bytes)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Load the contents of this input from a file
|
||||
#[cfg(feature = "std")]
|
||||
fn from_file<P>(path: P) -> Result<Self, Error>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let mut file = File::open(path)?;
|
||||
let mut bytes: Vec<u8> = vec![];
|
||||
file.read_to_end(&mut bytes)?;
|
||||
Ok(BytesInput::new(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
/// Rc Ref-cell from Input
|
||||
impl From<BytesInput> for Rc<RefCell<BytesInput>> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user