kszucs commented on a change in pull request #691: URL: https://github.com/apache/arrow-rs/pull/691#discussion_r691326418
########## File path: arrow/src/pyarrow.rs ########## @@ -0,0 +1,223 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! This library demonstrates a minimal usage of Rust's C data interface to pass +//! arrays from and to Python. + +use std::convert::{From, TryFrom}; +use std::sync::Arc; + +use libc::uintptr_t; +use pyo3::import_exception; +use pyo3::prelude::*; +use pyo3::types::PyList; + +use crate::array::{make_array, Array, ArrayData, ArrayRef}; +use crate::datatypes::{DataType, Field, Schema}; +use crate::error::ArrowError; +use crate::ffi; +use crate::ffi::FFI_ArrowSchema; +use crate::record_batch::RecordBatch; + +import_exception!(pyarrow, ArrowException); +pub type PyArrowException = ArrowException; + +impl From<ArrowError> for PyErr { + fn from(err: ArrowError) -> PyErr { + PyArrowException::new_err(err.to_string()) + } +} + +pub trait PyArrowConvert: Sized { + fn from_pyarrow(value: &PyAny) -> PyResult<Self>; + fn to_pyarrow(&self, py: Python) -> PyResult<PyObject>; Review comment: Perhaps we should split it into two conversion traits: `TryFromPyArrow` and `TryIntoPyArrow` ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
