Struct filmreel::cut::Register

source ·
pub struct Register { /* private fields */ }
Expand description

Holds Cut Variables and their corresponding values stored in a series of key/value pairs.

Cut Register

Implementations§

source§

impl Register

source

pub fn from<T: AsRef<str>>(json_string: T) -> Result<Register, FrError>

Creates a Register from a string ref

source

pub fn new() -> Self

source

pub fn to_string_pretty(&self) -> String

Pretty json formatting for Register serialization

source

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.

Cut Variable

source

pub fn get<K: AsRef<str>>(&self, key: K) -> Option<&Value>

Gets a reference to the string slice value for the given var name.

Cut Variable

source

pub fn iter(&self) -> Iter<'_, String, Value>

An iterator visiting all Cut Variables in arbitrary order.

source

pub fn contains_key(&self, key: &str) -> bool

Returns a boolean indicating whether [Register.vars] contains a given key.

Cut Variable

source

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.

  1. if the primary key of an incoming record matches with the key of an existing record:
    • update the matching target record.
  2. if the incoming key does not exist in any existing record:
    • add the incoming record to the target.
source

pub fn iter_merge<I>(registers: I) -> Register
where I: IntoIterator<Item = Register>,

Merges an iterable collection of registers together, left to right

source

pub fn single_merge(&mut self, other: Self)

Merges a single Register into the caller, overriding any values in self with other

source

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.

Read Operation

source

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.

Read Operation

source

pub fn expect_standalone_var( var_name: &str, frame_str: &str ) -> Result<(), FrError>

source

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

source

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.

source

pub fn flush_ignored(&mut self)

Flushes lowercase/ignored variable patters

Trait Implementations§

source§

impl Clone for Register

source§

fn clone(&self) -> Register

Returns a copy 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 Register

source§

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

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

impl Default for Register

source§

fn default() -> Register

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

impl<'de> Deserialize<'de> for Register

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 PartialEq for Register

source§

fn eq(&self, other: &Register) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Register

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
source§

impl TryFrom<PathBuf> for Register

§

type Error = FrError

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

fn try_from(path: PathBuf) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec<PathBuf>> for Register

§

type Error = FrError

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

fn try_from(paths: Vec<PathBuf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for Register

Auto Trait Implementations§

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> 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> ToOwned for T
where T: Clone,

§

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> ToStringHidden for T
where T: Serialize + ?Sized,

source§

fn to_string_hidden(&self) -> Result<String, FrError>

Pretty formatting for Register serialization, any cut variable names starting with an underscore are presented as ${_HIDDEN} in stdout

source§

impl<T> ToStringPretty for T
where T: Serialize + ?Sized,

source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

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