From fd0acd12ee6c8347d6c450970df5f92dc773df28 Mon Sep 17 00:00:00 2001 From: kennytm Date: Sun, 26 Apr 2015 23:47:27 +0800 Subject: [PATCH] Remove stability attributes. --- Cargo.toml | 4 +++- src/bin/qrencode.rs | 23 +++++++++++++++++++++++ src/bits.rs | 9 --------- src/lib.rs | 1 - src/optimize.rs | 2 -- src/types.rs | 12 ------------ 6 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 src/bin/qrencode.rs diff --git a/Cargo.toml b/Cargo.toml index 0b6c819..a607e02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "qrcode" description = "QR code encoder in Rust" license = "Apache-2.0" -version = "0.1.4" +version = "0.1.5" authors = ["kennytm "] keywords = ["qrcode"] repository = "https://github.com/kennytm/qrcode-rust" @@ -12,3 +12,5 @@ documentation = "http://www.rust-ci.org/kennytm/qrcode-rust/doc/qrcode/index.htm [dependencies] num = "*" +[[bin]] +name = "qrencode" diff --git a/src/bin/qrencode.rs b/src/bin/qrencode.rs new file mode 100644 index 0000000..db133ca --- /dev/null +++ b/src/bin/qrencode.rs @@ -0,0 +1,23 @@ +extern crate qrcode; + +use std::env; + +const SPACE: char = ' '; //' '; + +pub fn main() { + let arg = env::args().nth(1).unwrap(); + let code = qrcode::QrCode::new(arg.as_bytes()).unwrap(); + + print!("\n\n\n\n\n{}{}{}{}{}", SPACE, SPACE, SPACE, SPACE, SPACE); + + for y in 0 .. code.width() { + for x in 0 .. code.width() { + let block = if code[(x, y)] { '█' } else { SPACE }; + print!("{}{}", block, block); + } + print!("\n{}{}{}{}{}", SPACE, SPACE, SPACE, SPACE, SPACE); + } + + println!("\n\n\n\n"); +} + diff --git a/src/bits.rs b/src/bits.rs index 9ff59e1..c3c8fdb 100644 --- a/src/bits.rs +++ b/src/bits.rs @@ -1,5 +1,3 @@ -#![unstable] - //! The `bits` module encodes binary data into raw bits used in a QR code. use std::cmp::min; @@ -165,7 +163,6 @@ impl Bits { /// /// If the mode is not supported in the provided version, this method /// returns `Err(QrError::UnsupportedCharacterSet)`. - #[unstable] pub fn push_mode_indicator(&mut self, mode: ExtendedMode) -> QrResult<()> { let number = match (self.version, mode) { (Version::Micro(1), ExtendedMode::Data(Mode::Numeric)) => return Ok(()), @@ -308,7 +305,6 @@ impl Bits { /// Encodes a numeric string to the bits. /// /// The data should only contain the characters 0 to 9. - #[unstable] pub fn push_numeric_data(&mut self, data: &[u8]) -> QrResult<()> { try!(self.push_header(Mode::Numeric, data.len())); for chunk in data.chunks(3) { @@ -405,7 +401,6 @@ impl Bits { /// /// The data should only contain the charaters A to Z (excluding lowercase), /// 0 to 9, space, `$`, `%`, `*`, `+`, `-`, `.`, `/` or `:`. - #[unstable] pub fn push_alphanumeric_data(&mut self, data: &[u8]) -> QrResult<()> { try!(self.push_header(Mode::Alphanumeric, data.len())); for chunk in data.chunks(2) { @@ -453,7 +448,6 @@ mod alphanumeric_tests { impl Bits { /// Encodes 8-bit byte data to the bits. - #[unstable] pub fn push_byte_data(&mut self, data: &[u8]) -> QrResult<()> { try!(self.push_header(Mode::Byte, data.len())); for b in data { @@ -503,7 +497,6 @@ mod byte_tests { impl Bits { /// Encodes Shift JIS double-byte data to the bits. - #[unstable] pub fn push_kanji_data(&mut self, data: &[u8]) -> QrResult<()> { try!(self.push_header(Mode::Kanji, data.len()/2)); for kanji in data.chunks(2) { @@ -656,7 +649,6 @@ static DATA_LENGTHS: [[usize; 4]; 44] = [ impl Bits { /// Pushes the ending bits to indicate no more data. - #[unstable] pub fn push_terminator(&mut self, ec_level: EcLevel) -> QrResult<()> { let terminator_size = match self.version { Version::Micro(a) => (a as usize) * 2 + 1, @@ -842,7 +834,6 @@ pub fn encode_auto(data: &[u8], ec_level: EcLevel) -> QrResult { /// Finds the smallest version (QR code only) that can store N bits of data /// in the given error correction level. -#[unstable] fn find_min_version(length: usize, ec_level: EcLevel) -> Version { let mut min = 0; let mut max = 39; diff --git a/src/lib.rs b/src/lib.rs index 1e7c15e..9412943 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,6 @@ //! } //! -#![unstable] #![cfg_attr(test, feature(test))] // Unstable libraries #[cfg(test)] diff --git a/src/optimize.rs b/src/optimize.rs index 1461e12..1961ba7 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -1,5 +1,3 @@ -#![unstable] - //! Find the optimal data mode sequence to encode a piece of data. use std::slice::Iter; use types::{Mode, Version}; diff --git a/src/types.rs b/src/types.rs index c2bcba8..8327a66 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,3 @@ -#![unstable] - use std::default::Default; use std::cmp::{PartialOrd, Ordering}; use std::fmt::{Display, Formatter, Error}; @@ -8,7 +6,6 @@ use std::fmt::{Display, Formatter, Error}; //{{{ QrResult /// `QrError` encodes the error encountered when generating a QR code. -#[unstable] #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum QrError { /// The data is too long to encode into a QR code for the given version. @@ -43,7 +40,6 @@ impl Display for QrError { } /// `QrResult` is a convenient alias for a QR code generation result. -#[stable] pub type QrResult = Result; //}}} @@ -53,7 +49,6 @@ pub type QrResult = Result; /// The error correction level. It allows the original information be recovered /// even if parts of the code is damaged. #[derive(Debug, PartialEq, Eq, Copy, Clone, PartialOrd, Ord)] -#[unstable] pub enum EcLevel { /// Low error correction. Allows up to 7% of wrong blocks. L = 0, @@ -78,7 +73,6 @@ pub enum EcLevel { /// /// The smallest version is `Version::Normal(1)` of size 21×21, and the largest /// is `Version::Normal(40)` of size 177×177. -#[unstable] #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum Version { /// A normal QR code version. The parameter should be between 1 and 40. @@ -91,7 +85,6 @@ pub enum Version { impl Version { /// Get the number of "modules" on each size of the QR code, i.e. the width /// and height of the code. - #[unstable] pub fn width(&self) -> i16 { match *self { Version::Normal(v) => v * 4 + 17, @@ -127,7 +120,6 @@ impl Version { } /// The number of bits needed to encode the mode indicator. - #[unstable] pub fn mode_bits_count(&self) -> usize { match *self { Version::Micro(a) => (a - 1) as usize, @@ -136,7 +128,6 @@ impl Version { } /// Checks whether is version refers to a Micro QR code. - #[unstable] pub fn is_micro(&self) -> bool { match *self { Version::Normal(_) => false, @@ -151,7 +142,6 @@ impl Version { //{{{ Mode indicator /// The mode indicator, which specifies the character set of the encoded data. -#[unstable] #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum Mode { /// The data contains only characters 0 to 9. @@ -177,7 +167,6 @@ impl Mode { /// /// This method will return `Err(QrError::UnsupportedCharacterSet)` if the /// mode is not supported in the given version. - #[unstable] pub fn length_bits_count(&self, version: Version) -> usize { match version { Version::Micro(a) => { @@ -217,7 +206,6 @@ impl Mode { /// /// Note that in Kanji mode, the `raw_data_len` is the number of Kanjis, /// i.e. half the total size of bytes. - #[unstable] pub fn data_bits_count(&self, raw_data_len: usize) -> usize { match *self { Mode::Numeric => (raw_data_len * 10 + 2) / 3,