Struct Fact

Source
pub struct Fact {
    pub key: char,
    pub prior_key: Option<char>,
    pub next_key: Option<char>,
    pub pattern_placeholder: char,
    pub starts_with: u32,
    pub ends_with: u32,
    pub index_offset: u32,
}
Expand description

Represents a Fact for a character in a sample data entity that has been analyzed

Fields§

§key: char

the char that the fact defines (.e.g: ‘a’, ‘1’, ‘%’, etc.)

§prior_key: Option<char>

the char that appears before (-1) the key in the entity

§next_key: Option<char>

the char that appears after (+1) the key in the entity

§pattern_placeholder: char

the PatternPlaceholder symbol that represents the type of key

§starts_with: u32

indicates if the key is the first char in the entity (0=no, 1=yes)

§ends_with: u32

indicates if the key is the last char in the entity (0=no, 1=yes)

§index_offset: u32

indicates the number of positions from the index zero (where the char is located in the entity from the first position)

Implementations§

Source§

impl Fact

Source

pub fn new(k: char, pp: char, sw: u32, ew: u32, idx_off: u32) -> Fact

Constructs a new Fact

§Arguments
  • k: char - The char that the Fact represents (also known as the key).
  • pp: char - The char that represents the patter placeholder for the key.
  • sw: u32 - Indicates is the key is the first char in the entity. (0=no, 1=yes)
  • ew: u32 - Indicates is the key is the last char in the entity. (0=no, 1=yes)
  • idx_off: u32 - The index that represents the postion of the key from the beginning of the entity (zero based).
§Example
extern crate test_data_generation;

use test_data_generation::engine::Fact;

fn main() {
	//fact created for the character 'r' in the string "word"
   	let mut fact =  Fact::new('r','c',0,0,2);
}
Source

pub fn from_serialized(serialized: &str) -> Fact

Constructs a new Fact from a serialized (JSON) string of the Fact object. This is used when restoring from “archive”

§Arguments
  • serialized: &str - The JSON string that represents the archived Fact object.
§Example
extern crate test_data_generation;

use test_data_generation::engine::Fact;

fn main() {
	let serialized = "{\"key\":\"r\",\"prior_key\":null,\"next_key\":null,\"pattern_placeholder\":\"c\",\"starts_with\":0,\"ends_with\":0,\"index_offset\":2}";
	let mut fact = Fact::from_serialized(&serialized);
    fact.set_prior_key('a');
	fact.set_next_key('e');

	assert_eq!(fact.pattern_placeholder, 'c');
}
Source

pub fn serialize(&mut self) -> String

This function converts the Fact to a serialize JSON string.

§Example
extern crate test_data_generation;

use test_data_generation::engine::Fact;

fn main() {
	//fact created for the character 'r' in the string "word"
   	let mut fact =  Fact::new('r','c',0,0,2);

    println!("{}", fact.serialize());
    // {"key":"r","prior_key":null,"next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2}
}
Source

pub fn set_next_key(&mut self, nk: char)

This function sets the next key attribute to the specified char.

§Arguments
  • nk: char - The character that represents the next character in the entity
§Example
extern crate test_data_generation;

use test_data_generation::engine::Fact;

fn main() {
	//fact created for the character 'r' in the string "word"
   	let mut fact =  Fact::new('r','c',0,0,2);
    fact.set_next_key('d');
}
Source

pub fn set_prior_key(&mut self, pk: char)

This function sets the prior key attribute to the specified char.

§Arguments
  • pk: char - The character that represents the prior character in the entity
§Example
extern crate test_data_generation;

use test_data_generation::engine::Fact;

fn main() {
	//fact created for the character 'r' in the string "word"
   	let mut fact =  Fact::new('r','c',0,0,2);
    fact.set_prior_key('o');
}

Trait Implementations§

Source§

impl Clone for Fact

Source§

fn clone(&self) -> Fact

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Fact

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Fact

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Fact

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Fact

§

impl RefUnwindSafe for Fact

§

impl Send for Fact

§

impl Sync for Fact

§

impl Unpin for Fact

§

impl UnwindSafe for Fact

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,