-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split crate into a binary and a library
Split imdl into a binary, `src/main.rs`, and a library, `src/lib.rs`. This will enable benchmarking, fuzz testing, and anything that requires making `imdl` functions accessible another crate. type: reform
- Loading branch information
Showing
8 changed files
with
135 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use crate::*; | ||
use crate::common::*; | ||
|
||
#[derive(Debug, Eq, PartialEq, Copy, Clone)] | ||
pub(crate) struct Infohash { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#![deny(clippy::all, clippy::pedantic, clippy::restriction)] | ||
#![allow( | ||
clippy::else_if_without_else, | ||
clippy::enum_glob_use, | ||
clippy::float_arithmetic, | ||
clippy::float_cmp, | ||
clippy::implicit_return, | ||
clippy::indexing_slicing, | ||
clippy::integer_arithmetic, | ||
clippy::integer_division, | ||
clippy::large_enum_variant, | ||
clippy::missing_docs_in_private_items, | ||
clippy::missing_inline_in_public_items, | ||
clippy::needless_pass_by_value, | ||
clippy::non_ascii_literal, | ||
clippy::option_map_unwrap_or_else, | ||
clippy::shadow_reuse, | ||
clippy::struct_excessive_bools, | ||
clippy::too_many_lines, | ||
clippy::unseparated_literal_suffix, | ||
clippy::wildcard_enum_match_arm, | ||
clippy::wildcard_imports | ||
)] | ||
|
||
#[cfg(test)] | ||
#[macro_use] | ||
mod assert_matches; | ||
|
||
#[macro_use] | ||
mod errln; | ||
|
||
#[macro_use] | ||
mod err; | ||
|
||
#[macro_use] | ||
mod out; | ||
|
||
#[macro_use] | ||
mod outln; | ||
|
||
#[cfg(test)] | ||
#[macro_use] | ||
mod test_env; | ||
|
||
#[cfg(test)] | ||
mod test_env_builder; | ||
|
||
#[cfg(test)] | ||
mod capture; | ||
|
||
mod arguments; | ||
mod bytes; | ||
mod common; | ||
mod consts; | ||
mod env; | ||
mod error; | ||
mod file_error; | ||
mod file_info; | ||
mod file_path; | ||
mod file_status; | ||
mod files; | ||
mod hasher; | ||
mod host_port; | ||
mod host_port_parse_error; | ||
mod info; | ||
mod infohash; | ||
mod input; | ||
mod input_stream; | ||
mod input_target; | ||
mod into_u64; | ||
mod into_usize; | ||
mod invariant; | ||
mod lint; | ||
mod linter; | ||
mod magnet_link; | ||
mod md5_digest; | ||
mod metainfo; | ||
mod metainfo_error; | ||
mod mode; | ||
mod options; | ||
mod output_stream; | ||
mod output_target; | ||
mod piece_length_picker; | ||
mod piece_list; | ||
mod platform; | ||
mod platform_interface; | ||
mod print; | ||
mod reckoner; | ||
mod run; | ||
mod sha1_digest; | ||
mod shell; | ||
mod sort_key; | ||
mod sort_order; | ||
mod sort_spec; | ||
mod status; | ||
mod step; | ||
mod style; | ||
mod subcommand; | ||
mod table; | ||
mod torrent_summary; | ||
mod use_color; | ||
mod verifier; | ||
mod walker; | ||
mod xor_args; | ||
|
||
pub use run::run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,5 @@ | ||
#![deny(clippy::all, clippy::pedantic, clippy::restriction)] | ||
#![allow( | ||
clippy::else_if_without_else, | ||
clippy::enum_glob_use, | ||
clippy::float_arithmetic, | ||
clippy::float_cmp, | ||
clippy::implicit_return, | ||
clippy::indexing_slicing, | ||
clippy::integer_arithmetic, | ||
clippy::integer_division, | ||
clippy::large_enum_variant, | ||
clippy::missing_docs_in_private_items, | ||
clippy::needless_pass_by_value, | ||
clippy::non_ascii_literal, | ||
clippy::option_map_unwrap_or_else, | ||
clippy::shadow_reuse, | ||
clippy::too_many_lines, | ||
clippy::unseparated_literal_suffix, | ||
clippy::wildcard_enum_match_arm, | ||
clippy::wildcard_imports, | ||
clippy::struct_excessive_bools | ||
)] | ||
|
||
use crate::common::*; | ||
|
||
#[cfg(test)] | ||
#[macro_use] | ||
mod assert_matches; | ||
|
||
#[macro_use] | ||
mod errln; | ||
|
||
#[macro_use] | ||
mod err; | ||
|
||
#[macro_use] | ||
mod out; | ||
|
||
#[macro_use] | ||
mod outln; | ||
|
||
#[cfg(test)] | ||
#[macro_use] | ||
mod test_env; | ||
|
||
#[cfg(test)] | ||
mod test_env_builder; | ||
|
||
#[cfg(test)] | ||
mod capture; | ||
|
||
mod arguments; | ||
mod bytes; | ||
mod common; | ||
mod consts; | ||
mod env; | ||
mod error; | ||
mod file_error; | ||
mod file_info; | ||
mod file_path; | ||
mod file_status; | ||
mod files; | ||
mod hasher; | ||
mod host_port; | ||
mod host_port_parse_error; | ||
mod info; | ||
mod infohash; | ||
mod input; | ||
mod input_stream; | ||
mod input_target; | ||
mod into_u64; | ||
mod into_usize; | ||
mod invariant; | ||
mod lint; | ||
mod linter; | ||
mod magnet_link; | ||
mod md5_digest; | ||
mod metainfo; | ||
mod metainfo_error; | ||
mod mode; | ||
mod options; | ||
mod output_stream; | ||
mod output_target; | ||
mod piece_length_picker; | ||
mod piece_list; | ||
mod platform; | ||
mod platform_interface; | ||
mod print; | ||
mod reckoner; | ||
mod sha1_digest; | ||
mod shell; | ||
mod sort_key; | ||
mod sort_order; | ||
mod sort_spec; | ||
mod status; | ||
mod step; | ||
mod style; | ||
mod subcommand; | ||
mod table; | ||
mod torrent_summary; | ||
mod use_color; | ||
mod verifier; | ||
mod walker; | ||
mod xor_args; | ||
|
||
fn main() { | ||
if let Err(code) = Env::main().status() { | ||
process::exit(code); | ||
if let Err(code) = imdl::run() { | ||
std::process::exit(code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::common::*; | ||
|
||
/// Entry point into the IMDL binary. | ||
/// | ||
/// Called by `main` in `main.rs`. | ||
/// | ||
/// Constructs an `Env` using `Env::main`, containing the command line | ||
/// arguments, the current working directory, a handle to standard error, | ||
/// standard output, and standard input. | ||
/// | ||
/// Calls `Env::status` which runs the program, prints error messages, and | ||
/// returns a status code in case there was an error. | ||
/// | ||
/// Errors | ||
/// ------ | ||
/// | ||
/// In case of an error, a nonzero status code is returned. This status code can | ||
/// be passed to `std::process::exit`, to exit the process and report its | ||
/// failure to the system. | ||
pub fn run() -> Result<(), i32> { | ||
Env::main().status() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use super::*; | ||
use crate::common::*; | ||
|
||
use structopt::clap; | ||
|
||
|