Struct Row

Source
pub struct Row {
    pub operation: Operation,
    pub columns: HashMap<String, String>,
    pub finalized: bool,
    /* private fields */
}

Fields§

§operation: Operation

Verify that we don’t try to delete the same row as we’re creating it

§columns: HashMap<String, String>

Map of field name to its last change

§finalized: bool
👎Deprecated: The finalization state is now implicitly handled by the operation field.

Finalized: Last update or delete

Implementations§

Source§

impl Row

Source

pub fn new() -> Self

👎Deprecated: Do now create a new row manually, use the Tables API instead like create_row, upsert_row, update_row, or delete_row

Do not use Now broken, use the Tables API instead like create_row, upsert_row, update_row, or delete_row. Kept for code compilation but it’s expected that this was never used in practice.

Source

pub fn set<T: ToDatabaseValue>(&mut self, name: &str, value: T) -> &mut Self

Set a field to a value, this is the standard method for setting fields in a row.

This method ensures that the value is converted to a database-compatible format using the ToDatabaseValue trait. It is the primary way to set fields in a row for most use cases.

The ToDatabaseValue trait is implemented for various types, including primitive types, strings, and custom types. This allows you to set fields with different types of values without worrying about the underlying conversion. Check example for more details.

Check ToDatabaseValue for implemented automatic conversions.

§Panics

This method will panic if called on a row marked for deletion.

§Example
use substreams::scalar::{BigInt, BigDecimal};
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
let row = tables.create_row("myevent", "my_key");
row.set("name", "asset name");
row.set("decimals", 42);
row.set("count", BigDecimal::from(42));
row.set("value", BigInt::from(42));
Source

pub fn set_raw(&mut self, name: &str, value: String) -> &mut Self

Set a field to a raw value, this is useful for setting values that are not normalized across all databases. In there, you can put the raw value as you would in a SQL statement of the database you are targeting.

This will be pass as a string to the database which will interpret it itself.

Trait Implementations§

Source§

impl Debug for Row

Source§

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

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

impl Default for Row

Source§

fn default() -> Row

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

Auto Trait Implementations§

§

impl Freeze for Row

§

impl RefUnwindSafe for Row

§

impl Send for Row

§

impl Sync for Row

§

impl Unpin for Row

§

impl UnwindSafe for Row

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, 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.