keyfork/crates/qrcode/keyfork-zbar/src/symbol.rs

40 lines
756 B
Rust
Raw Normal View History

2024-01-16 02:44:48 +00:00
//!
2024-01-13 07:52:43 +00:00
use super::sys;
2024-01-16 02:44:48 +00:00
/// The type of symbol (i.e. what type of barcode or QR code).
2024-01-13 07:52:43 +00:00
pub use sys::zbar_symbol_type_e as SymbolType;
// TODO: config, modifiers
2024-01-16 02:44:48 +00:00
/// A Symbol detected by zbar.
2024-01-13 07:52:43 +00:00
#[derive(Debug)]
pub struct Symbol {
_type: SymbolType,
data: Vec<u8>,
}
impl Symbol {
pub(crate) fn new(_type: SymbolType, data: &[u8]) -> Self {
Self {
_type,
data: data.to_vec(),
}
}
2024-01-16 02:44:48 +00:00
/// The type of symbol
2024-01-13 07:52:43 +00:00
pub fn _type(&self) -> SymbolType {
self._type
}
2024-01-16 02:44:48 +00:00
/// The internal data of the image.
2024-01-13 07:52:43 +00:00
pub fn data(&self) -> &[u8] {
self.data.as_slice()
}
2024-01-16 02:44:48 +00:00
/// Consume self, returning the internal data.
2024-01-13 07:52:43 +00:00
pub fn into_data(self) -> Vec<u8> {
self.data
}
}