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 strThe 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 strThe 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 strThe 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: LineEndingHow 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.