Struct mysql::LocalInfileHandler [] [src]

pub struct LocalInfileHandler(_);

Callback to handle requests for local files. Consult Mysql documentation for the format of local infile data.

conn.query("CREATE TEMPORARY TABLE x.tbl(a TEXT)").unwrap();

conn.set_local_infile_handler(Some(
    LocalInfileHandler::new(|file_name, writer| {
        writer.write_all(b"row1: file name is ")?;
        writer.write_all(file_name)?;
        writer.write_all(b"\n")?;

        writer.write_all(b"row2: foobar\n")
    })
));

conn.query("LOAD DATA LOCAL INFILE 'file_name' INTO TABLE x.tbl").unwrap();

let mut row_num = 0;
for (row_idx, row) in conn.query("SELECT * FROM x.tbl").unwrap().enumerate() {
    row_num = row_idx + 1;
    let row: (String,) = from_row(row.unwrap());
    match row_num {
        1 => assert_eq!(row.0, "row1: file name is file_name"),
        2 => assert_eq!(row.0, "row2: foobar"),
        _ => unreachable!(),
    }
}

assert_eq!(row_num, 2);

Methods

impl LocalInfileHandler
[src]

Trait Implementations

impl Clone for LocalInfileHandler
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for LocalInfileHandler
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for LocalInfileHandler
[src]

impl Debug for LocalInfileHandler
[src]

Formats the value using the given formatter.