Skip to main content

CustomerCsv

Struct CustomerCsv 

Source
pub struct CustomerCsv<'a> { /* private fields */ }
Expand description

Write Customers in CSV format.

§Example

// Output the first 3 rows in CSV format
let generator = CustomerGenerator::new(1.0, 1, 1);
let mut csv = String::new();
writeln!(&mut csv, "{}", CustomerCsv::header()).unwrap(); // write header
for line in generator.iter().take(3) {
  // write line using CSV formatter
  writeln!(&mut csv, "{}", CustomerCsv::new(line)).unwrap();
}
assert_eq!(
  csv,
  "c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment\n\
   1,Customer#000000001,\"IVhzIApeRb ot,c,E\",15,25-989-741-2988,711.56,BUILDING,\"to the even, regular platelets. regular, ironic epitaphs nag e\"\n\
   2,Customer#000000002,\"XSTf4,NCwDVaWNe6tEgvwfmRchLXak\",13,23-768-687-3665,121.65,AUTOMOBILE,\"l accounts. blithely ironic theodolites integrate boldly: caref\"\n\
   3,Customer#000000003,\"MG9kdTD2WBHm\",1,11-719-748-3364,7498.12,AUTOMOBILE,\" deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov\"\n"
);

Implementations§

Source§

impl<'a> CustomerCsv<'a>

Source

pub fn new(inner: Customer<'a>) -> Self

Source

pub fn with_delimiter(inner: Customer<'a>, delimiter: char) -> Self

Create a new CustomerCsv with a custom delimiter

Source

pub fn header() -> &'static str

Returns the CSV header for the Customer table

Source

pub fn header_with_delimiter(delimiter: char) -> String

Returns the CSV header with a custom delimiter

Trait Implementations§

Source§

impl Display for CustomerCsv<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CustomerCsv<'a>

§

impl<'a> RefUnwindSafe for CustomerCsv<'a>

§

impl<'a> Send for CustomerCsv<'a>

§

impl<'a> Sync for CustomerCsv<'a>

§

impl<'a> Unpin for CustomerCsv<'a>

§

impl<'a> UnsafeUnpin for CustomerCsv<'a>

§

impl<'a> UnwindSafe for CustomerCsv<'a>

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, 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.