diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6464193..45edbb3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,7 @@ on: push: branches: ['**'] pull_request: - branches: ['main'] + branches: ['**'] env: CARGO_TERM_COLOR: always diff --git a/Cargo.lock b/Cargo.lock index 24542e6..1a3046f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,6 +505,30 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "paperjet" +version = "0.1.0" +dependencies = [ + "bindgen", + "clap", + "strum", + "thiserror", + "uuid", +] + +[[package]] +name = "paperjet-cli" +version = "0.1.0" +dependencies = [ + "anyhow", + "bincode", + "clap", + "colored", + "dirs", + "paperjet", + "pdfium-render", +] + [[package]] name = "pdfium-render" version = "0.8.34" @@ -547,22 +571,6 @@ dependencies = [ "syn", ] -[[package]] -name = "printrs" -version = "0.1.0" -dependencies = [ - "anyhow", - "bincode", - "bindgen", - "clap", - "colored", - "dirs", - "pdfium-render", - "strum", - "thiserror", - "uuid", -] - [[package]] name = "proc-macro2" version = "1.0.95" diff --git a/Cargo.toml b/Cargo.toml index 09dbf0f..08e3ab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,29 +1,9 @@ -[package] -name = "printrs" -version = "0.1.0" -edition = "2024" - -[lib] -name = "printrs" -path = "src/lib.rs" -doctest = false - -[[bin]] -name = "printrs" -path = "src/main.rs" - -[dependencies] -anyhow = "1.0.98" -bincode = "2.0.1" -clap = { version = "4.5.42", features = ["color", "derive"] } -colored = "3.0.0" -dirs = "6.0.0" -pdfium-render = "0.8.34" -strum = { version = "0.27.2", features = ["derive"] } -thiserror = "2.0.12" - -[dev-dependencies] -uuid = { version = "1.17.0", features = ["v4"] } - -[build-dependencies] -bindgen = "0.72.0" +[workspace] +resolver = "3" +members = ["paperjet", "paperjet-cli"] + +[profile.release] +opt-level = 3 +strip = "symbols" +lto = "fat" +codegen-units = 1 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE b/LICENSE-MIT similarity index 100% rename from LICENSE rename to LICENSE-MIT diff --git a/README.md b/README.md index 4a94572..29d3e13 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,26 @@ -# printrs 🖨️ +# paperjet 🖨️ > [!WARNING] > Windows is currently not supported. ## Requirements -Make sure you have `CUPS` installed. -On Linux based systems, you might also need `libcups2-dev` to link against `CUPS` during the build process. -To generate bindings, you will also need `libclang-dev`. -You can install both using your system's package manager, for example: +You will need the [Rust toolchain](https://www.rust-lang.org/tools/install). + +On Unix and macOS, you will need CUPS, which most likely is already installed. +For development, you will also need `libcups2-dev` and `liblcang-dev`. +You can install all of the above using your system's package manager, for example: ```sh sudo apt install cups libcups2-dev libclang-dev ``` -You will also need the [Rust toolchain](https://www.rust-lang.org/tools/install). +For PDF transformations, PDFium is currently used, and can be linked dynamically after building +the executable. +You can download the PDFium binary [here](https://github.com/bblanchon/pdfium-binaries/releases) +and put it in `target/debug` or `target/release` after the Rust executable is built. + +Switching to static linking is planned, so that there is no manual downloading required. ## Build @@ -27,7 +33,7 @@ cargo build -r and run with: ```sh -./target/release/printrs --help +./target/release/paperjet --help ``` Alternatively, build and run directly with one command: diff --git a/paperjet-cli/Cargo.toml b/paperjet-cli/Cargo.toml new file mode 100644 index 0000000..9a4fedb --- /dev/null +++ b/paperjet-cli/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "paperjet-cli" +version = "0.1.0" +edition = "2024" +license = "MIT OR Apache-2.0" +publish = false + +[[bin]] +name = "paperjet" +path = "src/main.rs" +publish = false + +[dependencies] +paperjet = { path = "../paperjet" } +anyhow = "1.0.98" +bincode = "2.0.1" +clap = { version = "4.5.42", features = ["color", "derive"] } +colored = "3.0.0" +dirs = "6.0.0" +pdfium-render = "0.8.34" diff --git a/paperjet-cli/LICENSE-APACHE b/paperjet-cli/LICENSE-APACHE new file mode 120000 index 0000000..965b606 --- /dev/null +++ b/paperjet-cli/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/paperjet-cli/LICENSE-MIT b/paperjet-cli/LICENSE-MIT new file mode 120000 index 0000000..76219eb --- /dev/null +++ b/paperjet-cli/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/paperjet-cli/README.md b/paperjet-cli/README.md new file mode 100644 index 0000000..9797a51 --- /dev/null +++ b/paperjet-cli/README.md @@ -0,0 +1,3 @@ +# paperjet + +A printing CLI, written in Rust. diff --git a/src/cli/args.rs b/paperjet-cli/src/cli/args.rs similarity index 99% rename from src/cli/args.rs rename to paperjet-cli/src/cli/args.rs index d214f6b..a33402f 100644 --- a/src/cli/args.rs +++ b/paperjet-cli/src/cli/args.rs @@ -2,7 +2,7 @@ use clap::builder::Styles; use clap::builder::styling::AnsiColor; use clap::{ArgAction, Parser, Subcommand}; use pdfium_render::prelude::PdfPageIndex; -use printrs::options::{ +use paperjet::options::{ ColorMode, Finishing, MediaSize, MediaSource, MediaType, Orientation, Quality, SidesMode, }; use std::ffi::c_int; diff --git a/src/cli/commands/display.rs b/paperjet-cli/src/cli/commands/display.rs similarity index 99% rename from src/cli/commands/display.rs rename to paperjet-cli/src/cli/commands/display.rs index f2f3371..79a8e08 100644 --- a/src/cli/commands/display.rs +++ b/paperjet-cli/src/cli/commands/display.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use anyhow::{Result, anyhow}; use colored::Colorize; -use printrs::Printer; +use paperjet::Printer; use crate::cli::args::DisplayArgs; use crate::cli::common; diff --git a/src/cli/commands/list.rs b/paperjet-cli/src/cli/commands/list.rs similarity index 100% rename from src/cli/commands/list.rs rename to paperjet-cli/src/cli/commands/list.rs diff --git a/src/cli/commands/mod.rs b/paperjet-cli/src/cli/commands/mod.rs similarity index 100% rename from src/cli/commands/mod.rs rename to paperjet-cli/src/cli/commands/mod.rs diff --git a/src/cli/commands/print/cmd.rs b/paperjet-cli/src/cli/commands/print/cmd.rs similarity index 90% rename from src/cli/commands/print/cmd.rs rename to paperjet-cli/src/cli/commands/print/cmd.rs index c0a5603..9f9dd25 100644 --- a/src/cli/commands/print/cmd.rs +++ b/paperjet-cli/src/cli/commands/print/cmd.rs @@ -4,8 +4,8 @@ use std::path::PathBuf; use anyhow::{Result, anyhow}; use colored::Colorize; -use printrs::Printer; -use printrs::options::PrintOptions; +use paperjet::Printer; +use paperjet::options::PrintOptions; use crate::cli::args::PrintArgs; use crate::cli::commands::print::{duplex, transform}; @@ -29,7 +29,7 @@ pub fn print(args: PrintArgs) -> Result<()> { // Simplex mode: submit to print let options = PrintOptions::from(&args); - printrs::print(documents, printer, options)?; + paperjet::print(documents, printer, options)?; println!("Files have been submitted for printing."); Ok(()) @@ -66,6 +66,6 @@ fn select_printer(args: &PrintArgs) -> Result { name.yellow() )) } else { - printrs::get_default_printer().ok_or(anyhow!("no default printer is available")) + paperjet::get_default_printer().ok_or(anyhow!("no default printer is available")) } } diff --git a/src/cli/commands/print/duplex.rs b/paperjet-cli/src/cli/commands/print/duplex.rs similarity index 94% rename from src/cli/commands/print/duplex.rs rename to paperjet-cli/src/cli/commands/print/duplex.rs index 97dbff3..28c25f7 100644 --- a/src/cli/commands/print/duplex.rs +++ b/paperjet-cli/src/cli/commands/print/duplex.rs @@ -2,9 +2,9 @@ use std::io::{self, Cursor, Read, Seek, Write}; use anyhow::{Result, anyhow, bail}; use colored::Colorize; +use paperjet::Printer; +use paperjet::options::PrintOptions; use pdfium_render::prelude::*; -use printrs::Printer; -use printrs::options::PrintOptions; use crate::cli::args::PrintArgs; use crate::cli::pdf; @@ -38,7 +38,7 @@ where // Start interactions println!("\nPrinting the front side..."); - printrs::print([front], printer.clone(), options.clone())?; + paperjet::print([front], printer.clone(), options.clone())?; println!("The front side has been submitted."); print!( @@ -50,7 +50,7 @@ where io::stdin().read_line(&mut input)?; println!("\nPrinting the back side..."); - printrs::print([back], printer, options)?; + paperjet::print([back], printer, options)?; println!("The back side has been submitted."); Ok(()) } @@ -104,7 +104,7 @@ where #[cfg(test)] mod tests { - use printrs::options::{CopiesInt, NumberUpInt, SidesMode}; + use paperjet::options::{CopiesInt, NumberUpInt, SidesMode}; use super::*; diff --git a/src/cli/commands/print/mod.rs b/paperjet-cli/src/cli/commands/print/mod.rs similarity index 100% rename from src/cli/commands/print/mod.rs rename to paperjet-cli/src/cli/commands/print/mod.rs diff --git a/src/cli/commands/print/transform.rs b/paperjet-cli/src/cli/commands/print/transform.rs similarity index 100% rename from src/cli/commands/print/transform.rs rename to paperjet-cli/src/cli/commands/print/transform.rs diff --git a/src/cli/common.rs b/paperjet-cli/src/cli/common.rs similarity index 91% rename from src/cli/common.rs rename to paperjet-cli/src/cli/common.rs index fee7bc6..f4e161b 100644 --- a/src/cli/common.rs +++ b/paperjet-cli/src/cli/common.rs @@ -1,14 +1,14 @@ use std::cmp::Ordering; -use printrs::Printer; -use printrs::options::{CopiesInt, NumberUpInt, PrintOptions}; +use paperjet::Printer; +use paperjet::options::{CopiesInt, NumberUpInt, PrintOptions}; use crate::cli::args::PrintArgs; use crate::cli::snapshot; /// Returns printers in a sorted order. pub fn get_sorted_printers() -> Vec { - let mut printers = printrs::get_printers(); + let mut printers = paperjet::get_printers(); printers.sort_by(|a, b| { if a.is_default { return Ordering::Less; @@ -31,7 +31,7 @@ pub fn get_printer_by_id(id: usize) -> Option { fn get_printer_by_id_from_snapshot(index: usize) -> Option { let snapshot = snapshot::printers::open()?; let entry = snapshot.get(index)?; - printrs::get_printer(&entry.identifier) + paperjet::get_printer(&entry.identifier) } /// Retrieves all printers from backend, then returns the printer with the specified index, /// if present. @@ -58,11 +58,11 @@ fn get_printer_by_name_from_snapshot(name: &str) -> Option { .iter() .find(|snap| snap.human_name.to_lowercase() == name.to_lowercase()) })?; - printrs::get_printer(&entry.identifier) + paperjet::get_printer(&entry.identifier) } // Retrieves the printer corresponding to the specified `name` from the API. fn get_printer_by_name_from_api(name: &str) -> Option { - let printers = printrs::get_printers(); + let printers = paperjet::get_printers(); printers.into_iter().find(|p| { p.identifier == name || p.name.to_lowercase() == name.to_lowercase() diff --git a/src/cli/mod.rs b/paperjet-cli/src/cli/mod.rs similarity index 100% rename from src/cli/mod.rs rename to paperjet-cli/src/cli/mod.rs diff --git a/src/cli/pdf/mod.rs b/paperjet-cli/src/cli/pdf/mod.rs similarity index 100% rename from src/cli/pdf/mod.rs rename to paperjet-cli/src/cli/pdf/mod.rs diff --git a/src/cli/pdf/slice.rs b/paperjet-cli/src/cli/pdf/slice.rs similarity index 100% rename from src/cli/pdf/slice.rs rename to paperjet-cli/src/cli/pdf/slice.rs diff --git a/src/cli/pdf/split.rs b/paperjet-cli/src/cli/pdf/split.rs similarity index 100% rename from src/cli/pdf/split.rs rename to paperjet-cli/src/cli/pdf/split.rs diff --git a/src/cli/snapshot.rs b/paperjet-cli/src/cli/snapshot.rs similarity index 99% rename from src/cli/snapshot.rs rename to paperjet-cli/src/cli/snapshot.rs index 31ab331..4e8ba7e 100644 --- a/src/cli/snapshot.rs +++ b/paperjet-cli/src/cli/snapshot.rs @@ -5,7 +5,7 @@ use std::time::Duration; use anyhow::Result; pub mod printers { - use printrs::Printer; + use paperjet::Printer; use super::*; diff --git a/src/main.rs b/paperjet-cli/src/main.rs similarity index 100% rename from src/main.rs rename to paperjet-cli/src/main.rs diff --git a/paperjet/Cargo.toml b/paperjet/Cargo.toml new file mode 100644 index 0000000..0e31b23 --- /dev/null +++ b/paperjet/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "paperjet" +version = "0.1.0" +edition = "2024" +description = "A printing library" +readme = "README.md" +repository = "https://github.com/stjomd/paperjet" +license = "MIT OR Apache-2.0" +keywords = ["print", "printer", "cups", "pdf"] +categories = ["multimedia"] + +[lib] +name = "paperjet" +path = "src/lib.rs" +doctest = false + +[dependencies] +clap = { version = "4.5.42", features = ["color", "derive"] } +strum = { version = "0.27.2", features = ["derive"] } +thiserror = "2.0.12" + +[dev-dependencies] +uuid = { version = "1.17.0", features = ["v4"] } + +[build-dependencies] +bindgen = "0.72.0" diff --git a/paperjet/LICENSE-APACHE b/paperjet/LICENSE-APACHE new file mode 120000 index 0000000..965b606 --- /dev/null +++ b/paperjet/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/paperjet/LICENSE-MIT b/paperjet/LICENSE-MIT new file mode 120000 index 0000000..76219eb --- /dev/null +++ b/paperjet/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/paperjet/README.md b/paperjet/README.md new file mode 100644 index 0000000..d1ef820 --- /dev/null +++ b/paperjet/README.md @@ -0,0 +1,5 @@ +# paperjet + +A printing library for Rust. +Supports getting printer information and submitting print jobs with various options. +Currently only supports macOS and Linux. diff --git a/build.rs b/paperjet/build.rs similarity index 100% rename from build.rs rename to paperjet/build.rs diff --git a/headers/cups.h b/paperjet/headers/cups.h similarity index 100% rename from headers/cups.h rename to paperjet/headers/cups.h diff --git a/src/lib.rs b/paperjet/src/lib.rs similarity index 100% rename from src/lib.rs rename to paperjet/src/lib.rs diff --git a/src/print/api.rs b/paperjet/src/print/api.rs similarity index 100% rename from src/print/api.rs rename to paperjet/src/print/api.rs diff --git a/src/print/error.rs b/paperjet/src/print/error.rs similarity index 100% rename from src/print/error.rs rename to paperjet/src/print/error.rs diff --git a/src/print/mod.rs b/paperjet/src/print/mod.rs similarity index 100% rename from src/print/mod.rs rename to paperjet/src/print/mod.rs diff --git a/src/print/options.rs b/paperjet/src/print/options.rs similarity index 100% rename from src/print/options.rs rename to paperjet/src/print/options.rs diff --git a/src/print/unix/cups.rs b/paperjet/src/print/unix/cups.rs similarity index 100% rename from src/print/unix/cups.rs rename to paperjet/src/print/unix/cups.rs diff --git a/src/print/unix/dest.rs b/paperjet/src/print/unix/dest.rs similarity index 100% rename from src/print/unix/dest.rs rename to paperjet/src/print/unix/dest.rs diff --git a/src/print/unix/job.rs b/paperjet/src/print/unix/job.rs similarity index 100% rename from src/print/unix/job.rs rename to paperjet/src/print/unix/job.rs diff --git a/src/print/unix/mod.rs b/paperjet/src/print/unix/mod.rs similarity index 100% rename from src/print/unix/mod.rs rename to paperjet/src/print/unix/mod.rs diff --git a/src/print/unix/native.rs b/paperjet/src/print/unix/native.rs similarity index 97% rename from src/print/unix/native.rs rename to paperjet/src/print/unix/native.rs index cf15071..84292ca 100644 --- a/src/print/unix/native.rs +++ b/paperjet/src/print/unix/native.rs @@ -41,7 +41,7 @@ impl CrossPlatformApi for PlatformSpecificApi { PrintError::NecessaryInformationMissing(String::from("no CUPS destination info")), )?; let cups_opts = add_options(options, &mut cups_dest, &mut cups_info)?; - let mut cups_job = CupsJob::try_new("printrs", cups_dest, cups_info, cups_opts)?; + let mut cups_job = CupsJob::try_new("paperjet", cups_dest, cups_info, cups_opts)?; cups_job.add_documents(readers)?; cups_job.print() diff --git a/src/print/unix/options.rs b/paperjet/src/print/unix/options.rs similarity index 100% rename from src/print/unix/options.rs rename to paperjet/src/print/unix/options.rs diff --git a/src/print/util/mod.rs b/paperjet/src/print/util/mod.rs similarity index 100% rename from src/print/util/mod.rs rename to paperjet/src/print/util/mod.rs diff --git a/tests/unix.rs b/paperjet/tests/unix.rs similarity index 80% rename from tests/unix.rs rename to paperjet/tests/unix.rs index 0550859..2f998a6 100644 --- a/tests/unix.rs +++ b/paperjet/tests/unix.rs @@ -2,7 +2,7 @@ mod utils; -use printrs::options::PrintOptions; +use paperjet::options::PrintOptions; use crate::utils::unixutils::FakePrinter; @@ -15,7 +15,7 @@ fn if_many_printers_exist_then_get_printers_returns_all() { FakePrinter::try_new(false).expect("Could not create a fake printer"), ]; // Get all printers: - let printers = printrs::get_printers(); + let printers = paperjet::get_printers(); // Each of the fake printers must be present in the vector returned by get_printers. // Since other printers may be present on the test runner's system, we can't make any other @@ -35,7 +35,7 @@ fn get_printer_returns_correct_information_of_printer() { // Create a fake printer: let fake = FakePrinter::try_new(false).expect("Could not create a fake printer"); // Get information: - let printer = printrs::get_printer(&fake.name).expect("Could not find the fake printer"); + let printer = paperjet::get_printer(&fake.name).expect("Could not find the fake printer"); // The fake printer should have correct information: assert_eq!(printer.name, fake.name); @@ -58,7 +58,7 @@ fn if_printer_exists_then_get_printer_returns_correct_printer() { // Create a fake printer: let fake = FakePrinter::try_new(false).expect("Could not create a fake printer"); // Get printer with the fake's name: - let printer = printrs::get_printer(&fake.name).expect("Could not find printer by name"); + let printer = paperjet::get_printer(&fake.name).expect("Could not find printer by name"); // get_printer should return the correct printer with the same name: assert_eq!( @@ -77,7 +77,7 @@ fn if_printer_not_exists_then_get_printer_returns_none() { fake.name.clone() }; // Get printer with the fake's name that does not exist anymore: - let printer = printrs::get_printer(&fake_name); + let printer = paperjet::get_printer(&fake_name); assert!( printer.is_none(), "Printer was dropped/removed but was found" @@ -92,9 +92,9 @@ fn if_printer_accepts_jobs_then_print_returns_unit() { let document = [0u8; 1024]; // Get the printer: - let printer = printrs::get_printer(&fake.name).expect("Could not find the fake printer"); + let printer = paperjet::get_printer(&fake.name).expect("Could not find the fake printer"); // Submit print job: - let result = printrs::print([&document[..]], printer, PrintOptions::default()); + let result = paperjet::print([&document[..]], printer, PrintOptions::default()); assert!( result.is_ok(), "Print job should be submitted successfully, but wasn't" @@ -109,9 +109,9 @@ fn if_printer_not_accepts_jobs_then_print_returns_err() { let document = [0u8; 1024]; // Get the printer: - let printer = printrs::get_printer(&fake.name).expect("Could not find the fake printer"); + let printer = paperjet::get_printer(&fake.name).expect("Could not find the fake printer"); // Submit print job: - let result = printrs::print([&document[..]], printer, PrintOptions::default()); + let result = paperjet::print([&document[..]], printer, PrintOptions::default()); assert!(result.is_err(), "Print job should not be accepted, but was"); } @@ -122,11 +122,11 @@ fn if_printer_no_longer_exists_then_print_returns_err() { // Create a mock document: let document = [0u8; 1024]; // Get the printer: - let printer = printrs::get_printer(&fake.name).expect("Could not find the fake printer"); + let printer = paperjet::get_printer(&fake.name).expect("Could not find the fake printer"); // Remove printer: drop(fake); // Submit print job: - let result = printrs::print([&document[..]], printer, PrintOptions::default()); + let result = paperjet::print([&document[..]], printer, PrintOptions::default()); assert!(result.is_err(), "Print job should not be accepted, but was"); } diff --git a/tests/utils/mod.rs b/paperjet/tests/utils/mod.rs similarity index 100% rename from tests/utils/mod.rs rename to paperjet/tests/utils/mod.rs diff --git a/tests/utils/unixutils.rs b/paperjet/tests/utils/unixutils.rs similarity index 95% rename from tests/utils/unixutils.rs rename to paperjet/tests/utils/unixutils.rs index 2941a3b..7e0dfc4 100644 --- a/tests/utils/unixutils.rs +++ b/paperjet/tests/utils/unixutils.rs @@ -11,7 +11,7 @@ pub struct FakePrinter { impl FakePrinter { /// Creates a new printer in the system with a random name and a URI to `/dev/null`. pub fn try_new(accept_jobs: bool) -> Result { - let name = "printrs-test-".to_owned() + &uuid::Uuid::new_v4().to_string(); + let name = "paperjet-test-".to_owned() + &uuid::Uuid::new_v4().to_string(); let device_uri = "file:/dev/null".to_owned(); let mut args = vec!["-p", &name, "-v", &device_uri];