Skip to main content

DelimitedFile

Struct DelimitedFile 

Source
pub struct DelimitedFile<'a> {
    pub path_literal: &'a str,
    pub directory_literal: &'a str,
    pub name: &'a str,
    pub columns: &'a [String],
    pub line_ending: LineEnding,
}
Expand description

One delimited source file, in every spelling an engine’s file relation may ask for it in — what SqlRenderer::delimited_file_relation_for is handed.

One struct rather than four arguments, because a slot that grows an argument is a slot every dialect has to be recompiled for; one that grows a field is not. Each is composed once, by the caller that knows the answer, so no dialect has to take a path apart to find a file name in it.

Fields§

§path_literal: &'a str

The whole path to the file, already a single-quoted SQL string literal and already escaped. Put it where the relation takes a path, and do not quote it again.

§directory_literal: &'a str

The directory the file sits in, already a single-quoted SQL string literal — for an engine that resolves a file name against a directory rather than opening a path.

§name: &'a str

The file’s own name inside that directory, bare: no quotes and no path in front of it.

§columns: &'a [String]

The file’s columns, in the order the file writes them, spelled exactly as its header row spells them and with no quoting applied.

Empty where the caller measured no header — a bundle assembled by hand. An engine that cannot read a file without its columns declared answers None to an empty list rather than guessing at one.

§line_ending: LineEnding

How the file’s lines end, as Razeri measured it when it read the file: LineEnding::CrLf for a carriage return and a newline, LineEnding::Lf for a newline alone.

Put it wherever the engine’s read names a record delimiter. An engine told \n for a file whose lines end \r\n either keeps the carriage return on the last field, so a name is stored one character too long and a number cannot be read, or, where the last field is quoted, reads past the closing quote into the next line. An engine whose read finds the ending itself can leave this alone, and should say so where it states its read.

Trait Implementations§

Source§

impl<'a> Clone for DelimitedFile<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for DelimitedFile<'a>

Source§

impl<'a> Debug for DelimitedFile<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DelimitedFile<'a>

§

impl<'a> RefUnwindSafe for DelimitedFile<'a>

§

impl<'a> Send for DelimitedFile<'a>

§

impl<'a> Sync for DelimitedFile<'a>

§

impl<'a> Unpin for DelimitedFile<'a>

§

impl<'a> UnsafeUnpin for DelimitedFile<'a>

§

impl<'a> UnwindSafe for DelimitedFile<'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> 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.