Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
feat: add missing functions to FunctionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Nov 9, 2022
1 parent 1d7ec85 commit 468cbad
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/function_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::as_string;
use crate::duckly::{
duckdb_function_get_bind_data, duckdb_function_get_init_data, duckdb_function_info,
duckdb_function_set_error,
duckdb_function_get_bind_data, duckdb_function_get_extra_info, duckdb_function_get_init_data,
duckdb_function_get_local_init_data, duckdb_function_info, duckdb_function_set_error,
};
use std::os::raw::c_char;

Expand All @@ -18,11 +18,36 @@ impl FunctionInfo {
duckdb_function_set_error(self.0, as_string!(error));
}
}
/// Gets the bind data set by [`BindInfo#set_bind_data`] during the bind.
///
/// Note that the bind data should be considered as read-only.
/// For tracking state, use the init data instead.
///
/// # Arguments
/// * `returns`: The bind data object
pub fn get_bind_data<T>(&self) -> *mut T {
unsafe { duckdb_function_get_bind_data(self.0) as *mut T }
unsafe { duckdb_function_get_bind_data(self.0).cast() }
}
/// Gets the init data set by [`InitInfo#set_init_data`] during the init.
///
/// # Arguments
/// * `returns`: The init data object
pub fn get_init_data<T>(&self) -> *mut T {
unsafe { duckdb_function_get_init_data(self.0) as *mut T }
unsafe { duckdb_function_get_init_data(self.0).cast() }
}
/// Retrieves the extra info of the function as set in [`TableFunction#set_extra_info`]
///
/// # Arguments
/// * `returns`: The extra info
pub fn get_extra_info<T>(&self) -> *mut T {
unsafe { duckdb_function_get_extra_info(self.0).cast() }
}
/// Gets the thread-local init data set by [`InitInfo#set_init_data`] during the local_init.
///
/// # Arguments
/// * `returns`: The init data object
pub fn get_local_init_data<T>(&self) -> *mut T {
unsafe { duckdb_function_get_local_init_data(self.0).cast() }
}
}

Expand Down

0 comments on commit 468cbad

Please sign in to comment.