Skip to content

Commit

Permalink
Merge pull request #632 from egrimley-arm/pr-rustfmt
Browse files Browse the repository at this point in the history
Tidy up all the Rust files with rustfmt --edition=2018.
  • Loading branch information
egrimley-arm authored Jul 28, 2023
2 parents a422d1a + 758b3c1 commit ef4c42e
Show file tree
Hide file tree
Showing 63 changed files with 410 additions and 334 deletions.
2 changes: 1 addition & 1 deletion examples/data-generators/csv-encoder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
//! file cannot be encoded, then the utility will abort with no output file
//! written.
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator for sdk/examples/idash2017-logistic-regression
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/image-processing
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/intersection-set-sum
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator for sdk/examples/linear-regression
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/moving-average-convergence-divergence
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/number-stream-accumulation
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
2 changes: 1 addition & 1 deletion examples/data-generators/postcard-generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator examples/rust-examples/postcard-native and postcard-wasm
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/private-set-intersection
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/private-set-intersection-sum
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/shamir-secret-sharing
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
2 changes: 1 addition & 1 deletion examples/data-generators/string-generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data generator sdk/examples/string-edit-distance
//!
//! # Authors
//! # Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
4 changes: 2 additions & 2 deletions examples/rust-examples/huffman-encoding/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
Cargo.lock
/target
Cargo.lock
4 changes: 2 additions & 2 deletions examples/rust-examples/logistic-regression/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logistic regression example, using an off-the-shelf Rust library for machine learning.
//!
//! ## Context
//! ## Context
//!
//! A number of competing supermarkets want to collectively pool some of their data on
//! customer preferences to be able to better compete against their larger competitors. However,
Expand All @@ -16,7 +16,7 @@
//! Ensured form of outputs: A Postcard-encoded Rust vector of `f64` values describing the
//! parameters of the learnt logistic regression model.
//!
//! ## Authors
//! ## Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! Assumed 'stream-2' : A Postcard-encoded Rust vector of `f64` values.
//! Ensured 'output' : A Postcard-encoded pair of `u64` and `f64`.
//!
//! ## Authors
//! ## Authors
//!
//! The Veracruz Development Team.
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! See the file `LICENSING.markdown` in the Veracruz root directory for licensing and
//! copyright information.


use anyhow;
use std::fs;

Expand Down
7 changes: 6 additions & 1 deletion examples/rust-examples/random-u32-list/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ use std::fs;

fn main() -> anyhow::Result<()> {
let output = "/output/unsorted_numbers.txt";
let bytes = rand::thread_rng().gen::<[u32; 32]>().iter().map(|n| n.to_string()).collect::<Vec<String>>().join(",");
let bytes = rand::thread_rng()
.gen::<[u32; 32]>()
.iter()
.map(|n| n.to_string())
.collect::<Vec<String>>()
.join(",");
println!("{}", bytes);
fs::write(output, bytes)?;
Ok(())
Expand Down
1 change: 0 additions & 1 deletion execution-engine/src/engines/wasmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,6 @@ impl WASMIRuntimeState {
let address = args.nth_checked::<u32>(0)?;
Self::convert_to_errno(self.vfs.fd_create(&mut self.memory()?, address))
}

}

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion execution-engine/src/engines/wasmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,6 @@ impl WasmtimeRuntimeState {
let mut vfs = lock_vfs!(caller_data);
Self::convert_to_errno(vfs.fd_create(&mut caller, address))
}

}

/// The `WasmtimeHostProvisioningState` implements everything needed to create a
Expand Down
45 changes: 25 additions & 20 deletions execution-engine/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,7 @@ impl InodeTable {
/// Assume `path` is an absolute path to a (special) file.
/// NOTE: this function is intended to be called after the root filesystem (handler) is
/// created.
fn install_services(
&mut self,
native_modules: Vec<NativeModule>,
) -> FileSystemResult<()> {
fn install_services(&mut self, native_modules: Vec<NativeModule>) -> FileSystemResult<()> {
for native_module in native_modules {
let path = match native_module.r#type() {
NativeModuleType::Static { special_file } => Some(special_file),
Expand Down Expand Up @@ -550,7 +547,7 @@ impl InodeTable {
let inode = self.get(inode);
match inode.map(|i| i.is_dir()).unwrap_or(false) {
true => Ok(inode?.read_dir(&self)?.iter().count() <= 2),
false => Ok(false)
false => Ok(false),
}
}

Expand Down Expand Up @@ -792,7 +789,10 @@ impl FileSystem {
/// and similar with respect to the parameter `std_streams_table`. Userspace
/// Wasm programs are going to expect that this is true, so we need to
/// preallocate some files corresponding to those, here.
pub fn new(rights_table: RightsTable, native_modules: Vec<NativeModule>) -> FileSystemResult<Self> {
pub fn new(
rights_table: RightsTable,
native_modules: Vec<NativeModule>,
) -> FileSystemResult<Self> {
let mut rst = Self {
fd_table: HashMap::new(),
next_fd_candidate: Self::FIRST_FD,
Expand Down Expand Up @@ -964,10 +964,7 @@ impl FileSystem {
Ok(())
}

fn install_services(
&mut self,
native_modules: Vec<NativeModule>,
) -> FileSystemResult<()> {
fn install_services(&mut self, native_modules: Vec<NativeModule>) -> FileSystemResult<()> {
self.lock_inode_table()?.install_services(native_modules)
}

Expand Down Expand Up @@ -1280,18 +1277,16 @@ impl FileSystem {
// If it is a service, call it.
// Warning: There is no input validity check performed here. It is the
// native module's responsibility to implement that.
if is_service
{
if is_service {
let (service, exec_config) = self
.lock_inode_table()?
.get_mut(&inode)?
.service_handler()?;
let native_module = service
.lock()
.map_err(|_| ErrNo::Busy)?;
let native_module = service.lock().map_err(|_| ErrNo::Busy)?;

// Invoke native module manager
let mut native_module_manager = NativeModuleManager::new(*native_module.clone(), self.service_fs()?);
let mut native_module_manager =
NativeModuleManager::new(*native_module.clone(), self.service_fs()?);
// Invoke native module with execution configuration
native_module_manager.execute(exec_config)?;
}
Expand Down Expand Up @@ -1918,7 +1913,10 @@ impl FileSystem {
// Convert the absolute path to relative path and then find the inode
let inode = self
.lock_inode_table()?
.get_inode_by_inode_path(&InodeTable::ROOT_DIRECTORY_INODE, strip_root_slash_path(path))?
.get_inode_by_inode_path(
&InodeTable::ROOT_DIRECTORY_INODE,
strip_root_slash_path(path),
)?
.0;
let mut rst = Vec::new();
if self.lock_inode_table()?.is_dir(&inode) {
Expand Down Expand Up @@ -1979,7 +1977,10 @@ impl FileSystem {
// Convert the absolute path to relative path and then find the inode
let inode = self
.lock_inode_table()?
.get_inode_by_inode_path(&InodeTable::ROOT_DIRECTORY_INODE, strip_root_slash_path(path))?
.get_inode_by_inode_path(
&InodeTable::ROOT_DIRECTORY_INODE,
strip_root_slash_path(path),
)?
.0;
let mut rst = Vec::new();
let mut top_level_files = Vec::new();
Expand All @@ -1988,7 +1989,10 @@ impl FileSystem {
let (all_dir, is_dir_empty) = {
let inode_table = self.lock_inode_table()?;
let inode_entry = inode_table.get(&inode)?;
(inode_entry.read_dir(&inode_table)?, inode_table.is_dir_empty(&inode))
(
inode_entry.read_dir(&inode_table)?,
inode_table.is_dir_empty(&inode),
)
};
if is_dir_empty? {
// Directory is empty (current and parent directories don't
Expand All @@ -2010,7 +2014,8 @@ impl FileSystem {
{
let mut sub_absolute_path = path.to_path_buf();
sub_absolute_path.push(sub_relative_path);
let (mut list, _) = self.read_all_files_and_dirs_by_absolute_path(&sub_absolute_path)?;
let (mut list, _) =
self.read_all_files_and_dirs_by_absolute_path(&sub_absolute_path)?;
rst.append(&mut list);
if path == Path::new("/") {
top_level_files.push(sub_absolute_path);
Expand Down
8 changes: 7 additions & 1 deletion execution-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,11 @@ pub fn execute(
pipeline: Box<Expr>,
options: &Options,
) -> anyhow::Result<u32> {
Ok(pipeline::execute_pipeline(strategy, &mut caller_filesystem, &pipepine_filesystem, pipeline, options)?)
Ok(pipeline::execute_pipeline(
strategy,
&mut caller_filesystem,
&pipepine_filesystem,
pipeline,
options,
)?)
}
Loading

0 comments on commit ef4c42e

Please sign in to comment.