Skip to content
Snippets Groups Projects
Commit 1ae2df2a authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

chore: remove nix dependency

parent c549b8d7
No related branches found
No related tags found
1 merge request!394chore: remove nix dependency
......@@ -3,6 +3,7 @@
# [?.?.?] Unreleased
### Added
- util::errno function for getting errno
### Changed
......
[package]
name = "tarantool"
description = "Tarantool rust bindings"
version = "3.0.2"
version = "3.1.0"
authors = [
"Dmitriy Koltsov <dkoltsov@picodata.io>",
"Georgy Moshkin <gmoshkin@picodata.io>",
......@@ -25,9 +25,8 @@ clap = {version = "3", features = ["derive", "env"]}
dlopen = "0.1.8"
dec = "0.4.8"
thiserror = "1.0.30"
libc = "0.2"
libc = { version = "0.2", features = ["extra_traits"] }
log = "0.4"
nix = "0.24.1"
num-traits = "0.2"
num-derive = "0.3"
once_cell = "1.4.0"
......
......@@ -3,6 +3,7 @@
#![allow(clippy::needless_return)]
#![allow(clippy::redundant_closure_call)]
#![allow(clippy::len_without_is_empty)]
#![allow(clippy::unnecessary_cast)]
//! Tarantool C API bindings for Rust.
//! This library contains the following Tarantool API's:
//!
......
use crate::error::{TarantoolError, TarantoolErrorCode};
use crate::ffi::tarantool as ffi;
use crate::set_error;
use nix::errno;
use crate::util::errno;
/// Set a callback to be called on Tarantool shutdown.
pub fn on_shutdown<F: FnOnce() + 'static>(cb: F) -> Result<(), TarantoolError> {
let cb_ptr = Box::into_raw(Box::new(cb));
if unsafe { ffi::box_on_shutdown(cb_ptr as _, Some(trampoline::<F>), None) } != 0 {
if errno::from_i32(errno::errno()) == errno::Errno::EINVAL {
if errno() == libc::EINVAL {
set_error!(
TarantoolErrorCode::IllegalParams,
"invalid arguments to on_shutdown"
......
......@@ -159,6 +159,20 @@ macro_rules! unwrap_ok_or {
}
}
////////////////////////////////////////////////////////////////////////////////
// errno
////////////////////////////////////////////////////////////////////////////////
#[inline(always)]
#[rustfmt::skip]
pub fn errno() -> i32 {
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
unsafe { *libc::__errno() as i32 }
#[cfg(target_os = "linux")]
unsafe { *libc::__errno_location() as i32 }
}
////////////////////////////////////////////////////////////////////////////////
// DisplayAsHexBytes
////////////////////////////////////////////////////////////////////////////////
......
......@@ -3,6 +3,7 @@
#![allow(clippy::needless_return)]
#![allow(clippy::redundant_closure_call)]
#![allow(clippy::len_without_is_empty)]
#![allow(clippy::unnecessary_cast)]
//! High-level zero-cost bindings for Lua (fork of
//! [hlua](https://crates.io/crates/hlua))
//!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment