Skip to main content

Given

Struct Given 

Source
pub struct Given {
    pub delimiter: Option<u8>,
    pub quote: Option<u8>,
    pub escape: Option<u8>,
    pub header: Option<bool>,
}
Expand description

What the caller said about how the file is written, where the sniffer would otherwise decide.

Every field is optional and a None means nothing was said, which is the common case and is the one the sniffer is for. What is given is not sniffed: read_csv('f.csv', delim=';') does not try the four candidates and pick one, it uses the semicolon, and a file that is really comma separated then comes back as one column. That is DuckDB’s behaviour and it is the useful one, since somebody who wrote the delimiter down knows something the first megabyte of the file does not say.

A given value also changes the block DuckDB prints under a conversion error, where a line reads (Set By User) rather than (Auto-Detected), which is why this is carried into the reader rather than folded into a Dialect and forgotten.

Fields§

§delimiter: Option<u8>

The byte between two fields.

§quote: Option<u8>

The byte that opens and closes a field.

§escape: Option<u8>

The byte that makes the next quote a literal one.

§header: Option<bool>

Whether the first line names the columns.

Implementations§

Source§

impl Given

Source

pub fn shown(given: Option<u8>, sniffed: Option<u8>) -> String

How a byte is written in the block under a conversion error, and where it came from.

Source

pub const fn source(given: bool) -> &'static str

What the block calls a value the caller gave and one it worked out.

Trait Implementations§

Source§

impl Clone for Given

Source§

fn clone(&self) -> Given

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Given

Source§

impl Debug for Given

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Given

Source§

fn default() -> Given

Returns the “default value” for a type. Read more
Source§

impl Eq for Given

Source§

impl PartialEq for Given

Source§

fn eq(&self, other: &Given) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Given

Auto Trait Implementations§

§

impl Freeze for Given

§

impl RefUnwindSafe for Given

§

impl Send for Given

§

impl Sync for Given

§

impl Unpin for Given

§

impl UnsafeUnpin for Given

§

impl UnwindSafe for Given

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.