pub struct Identifier {
    pub min_rarity: f32,
    pub max_rarity: f32,
    pub tags: Vec<String>,
    pub exclude_tags: Vec<String>,
    pub boundaryless: bool,
    pub file_support: bool,
}

Fields§

§min_rarity: f32

Keep Data having minimum Rarity of supplied min_rarity

§max_rarity: f32

Keep Data having maximum Rarity of supplied max_rarity

§tags: Vec<String>

Only include the Data which have at least one of the specified tags

§exclude_tags: Vec<String>

Only include Data which doesn’t have any of the excluded_tags

§boundaryless: bool

Use boundaryless regex

§file_support: bool

Scan files having supplied text as filename

Implementations§

source§

impl Identifier

source

pub fn min_rarity(self, rarity: f32) -> Self

source

pub fn max_rarity(self, rarity: f32) -> Self

source

pub fn include_tags(self, tags: &[String]) -> Self

source

pub fn exclude_tags(self, tags: &[String]) -> Self

source

pub fn boundaryless(self, boundaryless: bool) -> Self

source

pub fn file_support(self, support: bool) -> Self

source§

impl Identifier

source

pub fn identify(&self, text: &[u8]) -> Vec<Match>

Identify the given bytes.

Finds all possible identifications.

Arguments
  • text: &u8 - text which we want to identify
Examples
let identifier = lemmeknow::bytes::Identifier::default();
let text = b"UC11L3JDgDQMyH8iolKkVZ4w";
let result = identifier.identify(text);
assert_eq!(result[0].data.name, "YouTube Channel ID");
source

pub fn first_match(&self, text: &[u8]) -> Option<Match>

This returns the first identification.

Due to how data is stored, this means that the returned result has the highest rarity.

Arguments
  • text: &u8 - text which we want to identify
Examples
let identifier = lemmeknow::bytes::Identifier::default();
let some_result = identifier.first_match(b"8888888888");
let not_gonna_find = identifier.first_match(b"a friend for swanandx");
  
assert_eq!(some_result.unwrap().data.name, "Phone Number");
assert!(not_gonna_find.is_none());
source§

impl Identifier

source

pub fn to_json(result: &[Match]) -> String

Convert Vec<Match> to JSON

Returns prettified JSON string.

Helpful if you want to convert possible identifications to JSON for using in web APIs or something else.

Arguments
  • result: &Match - Reference to Vec<Match>.
Examples
use lemmeknow::Identifier;
let identifier = Identifier::default();
let result = identifier.identify("UC11L3JDgDQMyH8iolKkVZ4w");
let result_in_json = Identifier::to_json(&result);
println!("{result_in_json}");

Trait Implementations§

source§

impl Default for Identifier

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.