This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::{ | ||
duckly::{ | ||
duckdb_replacement_scan_add_parameter, duckdb_replacement_scan_info, | ||
duckdb_replacement_scan_set_error, duckdb_replacement_scan_set_function_name, | ||
}, | ||
Value, | ||
}; | ||
use std::ffi::CString; | ||
pub struct ReplacementScanInfo(pub(crate) duckdb_replacement_scan_info); | ||
|
||
impl ReplacementScanInfo { | ||
/// Sets the replacement function name to use. If this function is called in the replacement callback, the replacement scan is performed. If it is not called, the replacement callback is not performed. | ||
pub fn set_function_name(&mut self, function_name: &str) { | ||
unsafe { | ||
let function_name = CString::new(function_name).unwrap(); | ||
duckdb_replacement_scan_set_function_name(self.0, function_name.as_ptr()); | ||
} | ||
} | ||
/// Adds a parameter to the replacement scan function. | ||
pub fn add_parameter(&mut self, parameter: Value) { | ||
unsafe { | ||
duckdb_replacement_scan_add_parameter(self.0, parameter.0); | ||
} | ||
} | ||
/// Report that an error has occurred while executing the replacement scan. | ||
pub fn set_error(&mut self, error: &str) { | ||
unsafe { | ||
let error = CString::new(error).unwrap(); | ||
duckdb_replacement_scan_set_error(self.0, error.as_ptr()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters