Struct scylla::serialize::writers::CellWriter

source ·
pub struct CellWriter<'buf> { /* private fields */ }
Expand description

Represents a handle to a CQL value that needs to be written into.

The writer can either be transformed into a ready value right away (via set_null, set_unset or set_value or transformed into the CellValueBuilder in order to gradually initialize the value when the contents are not available straight away.

After the value is fully initialized, the handle is consumed and a WrittenCellProof object is returned in its stead. This is a type-level proof that the value was fully initialized and is used in SerializeCql::serialize in order to enforce the implementer to fully initialize the provided handle to CQL value.

Dropping this type without calling any of its methods will result in nothing being written.

Implementations§

source§

impl<'buf> CellWriter<'buf>

source

pub fn new(buf: &'buf mut Vec<u8>) -> CellWriter<'buf>

Creates a new cell writer based on an existing Vec.

The newly created row writer will append data to the end of the vec.

source

pub fn set_null(self) -> WrittenCellProof<'buf>

Sets this value to be null, consuming this object.

source

pub fn set_unset(self) -> WrittenCellProof<'buf>

Sets this value to represent an unset value, consuming this object.

source

pub fn set_value( self, contents: &[u8] ) -> Result<WrittenCellProof<'buf>, CellOverflowError>

Sets this value to a non-zero, non-unset value with given contents.

Prefer this to into_value_builder if you have all of the contents of the value ready up front (e.g. for fixed size types).

Fails if the contents size overflows the maximum allowed CQL cell size (which is i32::MAX).

source

pub fn into_value_builder(self) -> CellValueBuilder<'buf>

Turns this writter into a CellValueBuilder which can be used to gradually initialize the CQL value.

This method should be used if you don’t have all of the data up front, e.g. when serializing compound types such as collections or UDTs.

Auto Trait Implementations§

§

impl<'buf> Freeze for CellWriter<'buf>

§

impl<'buf> RefUnwindSafe for CellWriter<'buf>

§

impl<'buf> Send for CellWriter<'buf>

§

impl<'buf> Sync for CellWriter<'buf>

§

impl<'buf> Unpin for CellWriter<'buf>

§

impl<'buf> !UnwindSafe for CellWriter<'buf>

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

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

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