Enum ockam::SqlxType

source ·
pub enum SqlxType {
    Text(String),
    Blob(Vec<u8>),
    Integer(i64),
    Real(f64),
}
Expand description

This enum represents the set of types that we currently support in our database Since we support only Sqlite at the moment, those types are close to what is supported by Sqlite: https://www.sqlite.org/datatype3.html

The purpose of this type is to ease the serialization of data types in Ockam into data types in our database. For example, if we describe how to translate an Identifier into some Text then we can use the Text as a parameter in a sqlx query.

Note: see the ToSqlxType trait and its instances for how the conversion is done

Variants§

§

Text(String)

This type represents text in the database

§

Blob(Vec<u8>)

This type represents arbitrary bytes in the database

§

Integer(i64)

This type represents ints, signed or unsigned

§

Real(f64)

This type represents floats

Trait Implementations§

source§

impl Encode<'_, Sqlite> for SqlxType

The SqlType implements the Encode trait from sqlx to allow its values to be serialized to an Sqlite database. There is a 1 to 1 mapping with the database native types

source§

fn encode_by_ref( &self, buf: &mut <Sqlite as HasArguments<'_>>::ArgumentBuffer ) -> IsNull

Writes the value of self into buf without moving self. Read more
source§

fn produces(&self) -> Option<<Sqlite as Database>::TypeInfo>

§

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
§

fn size_hint(&self) -> usize

source§

impl Type<Sqlite> for SqlxType

The SqlxType implements the Type trait from sqlx to allow its values to be serialized to an Sqlite database

source§

fn type_info() -> <Sqlite as Database>::TypeInfo

Returns the canonical SQL type for this Rust type. Read more
§

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more