[−][src]Struct mysql::LocalInfileHandler
Callback to handle requests for local files. Consult Mysql documentation for the format of local infile data.
Support
Note that older versions of Mysql server may not support this functionality.
use mysql::prelude::Queryable; conn.query_drop("CREATE TEMPORARY TABLE mysql.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") }) )); match conn.query_drop("LOAD DATA LOCAL INFILE 'file_name' INTO TABLE mysql.tbl") { Ok(_) => (), Err(Error::MySqlError(ref e)) if e.code == 1148 => { // functionality is not supported by the server return; } err => { err.unwrap(); } } let mut row_num = 0; let result: Vec<String> = conn.query("SELECT * FROM mysql.tbl").unwrap(); assert_eq!( result, vec!["row1: file name is file_name".to_string(), "row2: foobar".to_string()], );
Implementations
impl LocalInfileHandler
[src]
pub fn new<F>(f: F) -> Self where
F: for<'a> FnMut(&'a [u8], &'a mut LocalInfile<'_>) -> Result<()> + Send + 'static,
[src]
F: for<'a> FnMut(&'a [u8], &'a mut LocalInfile<'_>) -> Result<()> + Send + 'static,
Trait Implementations
impl Clone for LocalInfileHandler
[src]
fn clone(&self) -> LocalInfileHandler
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for LocalInfileHandler
[src]
impl Eq for LocalInfileHandler
[src]
impl PartialEq<LocalInfileHandler> for LocalInfileHandler
[src]
Auto Trait Implementations
impl RefUnwindSafe for LocalInfileHandler
impl Send for LocalInfileHandler
impl Sync for LocalInfileHandler
impl Unpin for LocalInfileHandler
impl UnwindSafe for LocalInfileHandler
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,