cassandra_proto/types/blob.rs
1/// Special type that represents Cassandra blob type.
2#[derive(PartialEq, Eq, Hash, Debug, Clone)]
3pub struct Blob(Vec<u8>);
4
5impl Blob {
6 /// Constructor method that creates new blob value from a vector of bytes.
7 pub fn new(bytes: Vec<u8>) -> Self {
8 Blob(bytes)
9 }
10
11 /// Returns a mutable reference to an underlying slice of bytes.
12 pub fn as_mut_slice<'a>(&'a mut self) -> &'a [u8] {
13 self.0.as_mut_slice()
14 }
15
16 /// Returns underlying vector of bytes.
17 pub fn into_vec(self) -> Vec<u8> {
18 self.0
19 }
20}
21
22impl From<Vec<u8>> for Blob {
23 fn from(vec: Vec<u8>) -> Self {
24 Blob::new(vec)
25 }
26}