-
Notifications
You must be signed in to change notification settings - Fork 191
refactor(rust/core)!: move the ffi related stuff to the new adbc_ffi package #3381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7ff5fb5
02bdff2
ac320d5
624f404
5e98455
5429117
0c592a9
4a30192
d4abf20
449519a
2bc0fb3
0c1f0a7
88f525c
a5afb8f
c70a68e
c1b1a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ use std::{ffi::NulError, fmt::Display}; | |
|
|
||
| use arrow_schema::ArrowError; | ||
|
|
||
| use crate::constants; | ||
|
|
||
| pub type AdbcStatusCode = u8; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can't move this to the FFI crate because the TryFrom implementation has to be in this crate?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could move it and provide a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you guessed, I got stuck after my first attempt to move I believe it's better to keep this in adbc_core for the following reasons:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just return u8 on the FFI side. We only need u8 to AdbcStatus Into. Let's not have 2 layers of conversions for an enum.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I wrote in the comments below, I'm wondering if this should be placed in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine by me. I just don't want another layer of conversion/indirection. |
||
|
|
||
| /// Status of an operation. | ||
| #[derive(Debug, Copy, Clone, PartialEq, Eq)] | ||
| pub enum Status { | ||
|
|
@@ -153,3 +157,53 @@ impl From<std::ffi::IntoStringError> for Error { | |
| error.into() | ||
| } | ||
| } | ||
|
|
||
| impl TryFrom<AdbcStatusCode> for Status { | ||
| type Error = Error; | ||
|
|
||
| fn try_from(value: AdbcStatusCode) -> Result<Self> { | ||
| match value { | ||
| constants::ADBC_STATUS_OK => Ok(Status::Ok), | ||
| constants::ADBC_STATUS_UNKNOWN => Ok(Status::Unknown), | ||
| constants::ADBC_STATUS_NOT_IMPLEMENTED => Ok(Status::NotImplemented), | ||
| constants::ADBC_STATUS_NOT_FOUND => Ok(Status::NotFound), | ||
| constants::ADBC_STATUS_ALREADY_EXISTS => Ok(Status::AlreadyExists), | ||
| constants::ADBC_STATUS_INVALID_ARGUMENT => Ok(Status::InvalidArguments), | ||
| constants::ADBC_STATUS_INVALID_STATE => Ok(Status::InvalidState), | ||
| constants::ADBC_STATUS_INVALID_DATA => Ok(Status::InvalidData), | ||
| constants::ADBC_STATUS_INTEGRITY => Ok(Status::Integrity), | ||
| constants::ADBC_STATUS_INTERNAL => Ok(Status::Internal), | ||
| constants::ADBC_STATUS_IO => Ok(Status::IO), | ||
| constants::ADBC_STATUS_CANCELLED => Ok(Status::Cancelled), | ||
| constants::ADBC_STATUS_TIMEOUT => Ok(Status::Timeout), | ||
| constants::ADBC_STATUS_UNAUTHENTICATED => Ok(Status::Unauthenticated), | ||
| constants::ADBC_STATUS_UNAUTHORIZED => Ok(Status::Unauthorized), | ||
| v => Err(Error::with_message_and_status( | ||
| format!("Unknown status code: {v}"), | ||
| Status::InvalidData, | ||
| )), | ||
|
eitsupi marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<Status> for AdbcStatusCode { | ||
| fn from(value: Status) -> Self { | ||
| match value { | ||
| Status::Ok => constants::ADBC_STATUS_OK, | ||
| Status::Unknown => constants::ADBC_STATUS_UNKNOWN, | ||
| Status::NotImplemented => constants::ADBC_STATUS_NOT_IMPLEMENTED, | ||
| Status::NotFound => constants::ADBC_STATUS_NOT_FOUND, | ||
| Status::AlreadyExists => constants::ADBC_STATUS_ALREADY_EXISTS, | ||
| Status::InvalidArguments => constants::ADBC_STATUS_INVALID_ARGUMENT, | ||
| Status::InvalidState => constants::ADBC_STATUS_INVALID_STATE, | ||
| Status::InvalidData => constants::ADBC_STATUS_INVALID_DATA, | ||
| Status::Integrity => constants::ADBC_STATUS_INTEGRITY, | ||
| Status::Internal => constants::ADBC_STATUS_INTERNAL, | ||
| Status::IO => constants::ADBC_STATUS_IO, | ||
| Status::Cancelled => constants::ADBC_STATUS_CANCELLED, | ||
| Status::Timeout => constants::ADBC_STATUS_TIMEOUT, | ||
| Status::Unauthenticated => constants::ADBC_STATUS_UNAUTHENTICATED, | ||
| Status::Unauthorized => constants::ADBC_STATUS_UNAUTHORIZED, | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.