pub struct SimpleString(/* private fields */);
Implementations§
Source§impl SimpleString
Simple string type
impl SimpleString
Simple string type
Sourcepub fn new(value: &[u8]) -> Self
pub fn new(value: &[u8]) -> Self
Build a new Simple string
§Example
use resp_protocol::SimpleString;
let simple_string = SimpleString::new(b"OK");
Sourcepub fn bytes(&self) -> Bytes
pub fn bytes(&self) -> Bytes
use resp_protocol::SimpleString;
use bytes::Bytes;
let simple_string: SimpleString = SimpleString::new(b"OK");
let bytes: Bytes = simple_string.bytes();
println!("{:?}", bytes); // b"+OK\r\n"
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
use resp_protocol::SimpleString;
let simple_string: SimpleString = SimpleString::new(b"OK");
let length: usize = simple_string.len();
println!("{:?}", length); // 5
Sourcepub fn value(&self) -> Vec<u8> ⓘ
pub fn value(&self) -> Vec<u8> ⓘ
use resp_protocol::SimpleString;
let simple_string: SimpleString = SimpleString::new(b"OK");
let value: Vec<u8> = simple_string.value();
println!("{:?}", value); // [79, 75]
Sourcepub fn value_len(&self) -> usize
pub fn value_len(&self) -> usize
use resp_protocol::SimpleString;
let simple_string: SimpleString = SimpleString::new(b"OK");
let value_length: usize = simple_string.value_len();
println!("{:?}", value_length); // 2
pub fn validate_value(input: &[u8]) -> Result<(), RespError>
pub fn from_bytes(input: Bytes) -> Self
pub fn from_slice(input: &[u8]) -> Self
Sourcepub unsafe fn from_raw(ptr: *mut u8, length: usize) -> Self
pub unsafe fn from_raw(ptr: *mut u8, length: usize) -> Self
Build as new Simple String from raw pointer
§Example
use resp_protocol::SimpleString;
use std::mem::ManuallyDrop;
let string: String = "+OK\r\n".to_owned();
let mut mdrop_string: ManuallyDrop<String> = ManuallyDrop::new(string);
let simple_string: SimpleString = unsafe { SimpleString::from_raw(mdrop_string.as_mut_ptr(), mdrop_string.len()) };
pub fn while_valid( input: &[u8], start: &mut usize, end: &usize, ) -> Result<(), RespError>
pub fn parse( input: &[u8], start: &mut usize, end: &usize, ) -> Result<Self, RespError>
Trait Implementations§
Source§impl Clone for SimpleString
impl Clone for SimpleString
Source§fn clone(&self) -> SimpleString
fn clone(&self) -> SimpleString
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SimpleString
impl Debug for SimpleString
Source§impl PartialEq for SimpleString
impl PartialEq for SimpleString
impl StructuralPartialEq for SimpleString
Auto Trait Implementations§
impl !Freeze for SimpleString
impl RefUnwindSafe for SimpleString
impl Send for SimpleString
impl Sync for SimpleString
impl Unpin for SimpleString
impl UnwindSafe for SimpleString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more