[][src]Struct cql_tiny_text::TinyText

pub struct TinyText(_);

Tuple wrapping String for working with TinyText values in a CQL database.

Limited in size to 255 * 4 = 1020 bytes.

Methods

impl TinyText[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for TinyText[src]

impl CqlReadable for TinyText[src]

impl CqlStreamReadable for TinyText[src]

impl CqlType for TinyText[src]

type ValueType = Self

The type of value to read/write from the database.

impl CqlWritable for TinyText[src]

impl Debug for TinyText[src]

impl Default for TinyText[src]

impl Display for TinyText[src]

impl Eq for TinyText[src]

impl From<TinyText> for String[src]

impl Hash for TinyText[src]

impl Ord for TinyText[src]

impl PartialEq<TinyText> for TinyText[src]

impl PartialOrd<TinyText> for TinyText[src]

impl StructuralEq for TinyText[src]

impl StructuralPartialEq for TinyText[src]

impl<'_> TryFrom<&'_ str> for TinyText[src]

Attempts to convert the given &str to TinyText. Errors if the length of the &str excedes 1020 bytes.

Examples

use std::convert::TryFrom;

let small_string = "s".repeat(1020); // 1 byte per char
assert_eq!("s".repeat(1020), String::from(TinyText::try_from(small_string).unwrap()));

let big_string = "s".repeat(1021);
assert_eq!(Err(ValueTooLargeError), TinyText::try_from(big_string));

let small_utf8_string = "س".repeat(510); // 2 bytes per char
assert_eq!("س".repeat(510), String::from(TinyText::try_from(small_utf8_string).unwrap()));

let big_utf8_string = "س".repeat(511);
assert_eq!(Err(ValueTooLargeError), TinyText::try_from(big_utf8_string));

type Error = ValueTooLargeError

The type returned in the event of a conversion error.

impl TryFrom<String> for TinyText[src]

Attempts to convert the given string to TinyText. Errors if the length of the String excedes 1020 bytes.

Errors

Will return a ValueTooLargeError if the given string is larger than 1020 bytes.

Examples

use std::convert::TryFrom;

let small_string = "s".repeat(1020); // 1 byte per char
assert_eq!("s".repeat(1020), String::from(TinyText::try_from(small_string).unwrap()));

let big_string = "s".repeat(1021);
assert_eq!(Err(ValueTooLargeError), TinyText::try_from(big_string));

let small_utf8_string = "س".repeat(510); // 2 bytes per char
assert_eq!("س".repeat(510), String::from(TinyText::try_from(small_utf8_string).unwrap()));

let big_utf8_string = "س".repeat(511);
assert_eq!(Err(ValueTooLargeError), TinyText::try_from(big_utf8_string));

type Error = ValueTooLargeError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.