pub struct Register { /* private fields */ }
Expand description
Holds Cut Variables and their corresponding values stored in a series of key/value pairs.
Implementations§
source§impl Register
impl Register
sourcepub fn from<T: AsRef<str>>(json_string: T) -> Result<Register, FrError>
pub fn from<T: AsRef<str>>(json_string: T) -> Result<Register, FrError>
Creates a Register from a string ref
pub fn new() -> Self
sourcepub fn to_string_pretty(&self) -> String
pub fn to_string_pretty(&self) -> String
Pretty json formatting for Register serialization
sourcepub fn get_key_value<K: AsRef<str>>(&self, key: K) -> Option<(&String, &Value)>
pub fn get_key_value<K: AsRef<str>>(&self, key: K) -> Option<(&String, &Value)>
Gets a reference to the string slice value for the given var name.
sourcepub fn get<K: AsRef<str>>(&self, key: K) -> Option<&Value>
pub fn get<K: AsRef<str>>(&self, key: K) -> Option<&Value>
Gets a reference to the string slice value for the given var name.
sourcepub fn iter(&self) -> Iter<'_, String, Value>
pub fn iter(&self) -> Iter<'_, String, Value>
An iterator visiting all Cut Variables in arbitrary order.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns a boolean indicating whether [Register.vars
] contains a given key.
sourcepub fn destructive_merge<I>(&mut self, others: I)where
I: IntoIterator<Item = Register>,
pub fn destructive_merge<I>(&mut self, others: I)where
I: IntoIterator<Item = Register>,
Merges foreign Register
structs into the caller,
overriding any values in self
with the current others.next()
item.
- if the primary key of an incoming record matches with the key of an existing record:
- update the matching target record.
- if the incoming key does not exist in any existing record:
- add the incoming record to the target.
sourcepub fn iter_merge<I>(registers: I) -> Registerwhere
I: IntoIterator<Item = Register>,
pub fn iter_merge<I>(registers: I) -> Registerwhere
I: IntoIterator<Item = Register>,
Merges an iterable collection of registers together, left to right
sourcepub fn single_merge(&mut self, other: Self)
pub fn single_merge(&mut self, other: Self)
Merges a single Register
into the caller, overriding any values in self
with other
sourcepub fn read_match(&self, json_string: &str) -> Result<Vec<Match<'_>>, FrError>
pub fn read_match(&self, json_string: &str) -> Result<Vec<Match<'_>>, FrError>
Returns a vector of Match enums enums found in the string provided for use in cut operations.
sourcepub fn read_operation(
&self,
mat: Match<'_>,
value: &mut Value,
hide_vars: bool
) -> Result<(), FrError>
pub fn read_operation( &self, mat: Match<'_>, value: &mut Value, hide_vars: bool ) -> Result<(), FrError>
Replaces a byte range in a given string with the range given in the ::Match provided.
pub fn expect_standalone_var( var_name: &str, frame_str: &str ) -> Result<(), FrError>
sourcepub fn write_match(
var_name: &str,
frame_str: &str,
payload_str: &str
) -> Result<Option<String>, FrError>
pub fn write_match( var_name: &str, frame_str: &str, payload_str: &str ) -> Result<Option<String>, FrError>
Takes a crate::Frame
string value and compares it against a payload string value
returning any declared cut variables found
sourcepub fn write_operation(
&mut self,
key: &str,
val: Value
) -> Result<Option<Value>, FrError>
pub fn write_operation( &mut self, key: &str, val: Value ) -> Result<Option<Value>, FrError>
Inserts a Value entry into the Register’s Cut Variables
Returns an Err
if the key value is does not consist solely of characters, dashes, and underscores.
sourcepub fn flush_ignored(&mut self)
pub fn flush_ignored(&mut self)
Flushes lowercase/ignored variable patters
Trait Implementations§
source§impl<'de> Deserialize<'de> for Register
impl<'de> Deserialize<'de> for Register
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Register
impl PartialEq for Register
impl StructuralPartialEq for Register
Auto Trait Implementations§
impl Freeze for Register
impl RefUnwindSafe for Register
impl Send for Register
impl Sync for Register
impl Unpin for Register
impl UnwindSafe for Register
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ToStringHidden for T
impl<T> ToStringHidden for T
Pretty formatting for Register serialization, any cut variable names starting with an underscore are
presented as ${_HIDDEN}
in stdout