Struct binary_tuples::Tuple
[−]
[src]
pub struct Tuple { /* fields omitted */ }
A builder for serialized tuples
Methods
impl Tuple
[src]
pub fn new() -> Tuple
[src]
Create a new tuple
pub fn with_capacity(capacity: usize) -> Tuple
[src]
Create a new tuple with a fixed backing capacity
pub fn from_bytes(bytes: &[u8]) -> Tuple
[src]
Create a new tuple from an existing byte array
This can be used with as_segments
to parse an existing tuple into a list of segments
Examples
use binary_tuples::{Tuple, segment::Segment}; let binary = vec![2, 117, 115, 101, 114, 115, 0, 21, 1]; let tuple = Tuple::from_bytes(&binary) .as_segments() .unwrap(); assert_eq!(tuple, vec![Segment::String(String::from("users")), Segment::Integer(1)]);
pub fn add_segment(&mut self, input: &Segment)
[src]
Add an individual segment to this tuple.
Notes
It is recommended to import AddToTuple as it greatly simplifies this API
pub fn add_builder(&mut self, input: &Tuple)
[src]
Directly embed the contents of another tuple builder in this builder
Notes
This is more efficient than adding a segment slice as the backing buffer can be memcopied.
pub fn into_bytes(self) -> Vec<u8>
[src]
Return a serialized tuple
pub fn as_bytes(&self) -> &[u8]
[src]
Return a serialized tuple
pub fn as_segments(&self) -> Result<Vec<Segment>, TupleError>
[src]
Deserialize the segments which make up this tuple
Trait Implementations
impl Clone for Tuple
[src]
fn clone(&self) -> Tuple
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl AddToTuple<i64> for Tuple
[src]
fn add(&mut self, v: i64)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<String> for Tuple
[src]
fn add(&mut self, v: String)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl<'a> AddToTuple<&'a [u8]> for Tuple
[src]
fn add(&mut self, v: &'a [u8])
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl<'a> AddToTuple<&'a Vec<u8>> for Tuple
[src]
fn add(&mut self, v: &'a Vec<u8>)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<f32> for Tuple
[src]
fn add(&mut self, v: f32)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<f64> for Tuple
[src]
fn add(&mut self, v: f64)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<Vec<u8>> for Tuple
[src]
fn add(&mut self, v: Vec<u8>)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<&'static str> for Tuple
[src]
fn add(&mut self, v: &'static str)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<Uuid> for Tuple
[src]
fn add(&mut self, v: Uuid)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl AddToTuple<Vec<Segment>> for Tuple
[src]
fn add(&mut self, v: Vec<Segment>)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more
impl<'a> AddToTuple<&'a Tuple> for Tuple
[src]
fn add(&mut self, v: &'a Tuple)
[src]
Add a new segment to a tuple
fn with(self, input: T) -> Self
[src]
A fluent interface for adding a new segment to a tuple Read more