Skip to content

Commit 4155d08

Browse files
committed
chore(dependencies): remove libc crate from dependencies
1 parent d9c5d3b commit 4155d08

File tree

8 files changed

+22
-21
lines changed

8 files changed

+22
-21
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ http-body-util = { version = "0.1", optional = true }
3535
httparse = { version = "1.8", optional = true }
3636
httpdate = { version = "1.0", optional = true }
3737
itoa = { version = "1", optional = true }
38-
libc = { version = "0.2", optional = true }
3938
tracing = { version = "0.1", default-features = false, features = ["std"], optional = true }
4039
want = { version = "0.3", optional = true }
4140

@@ -82,7 +81,7 @@ client = ["dep:want"]
8281
server = ["dep:httpdate"]
8382

8483
# C-API support (currently unstable (no semver))
85-
ffi = ["dep:libc", "dep:http-body-util"]
84+
ffi = ["dep:http-body-util"]
8685

8786
# Utilize tracing (currently unstable)
8887
tracing = ["dep:tracing"]

src/ffi/body.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use std::ffi::c_void;
1+
use std::ffi::{c_int, c_void};
22
use std::mem::ManuallyDrop;
33
use std::ptr;
44
use std::task::{Context, Poll};
55

66
use http_body_util::BodyExt as _;
7-
use libc::{c_int, size_t};
87

98
use super::task::{hyper_context, hyper_task, hyper_task_return_type, AsTaskType};
109
use super::{UserDataPointer, HYPER_ITER_CONTINUE};
1110
use crate::body::{Bytes, Frame, Incoming as IncomingBody};
11+
use crate::ffi::size_t;
1212

1313
/// A streaming HTTP body.
1414
///

src/ffi/client.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use std::ffi::c_int;
12
use std::ptr;
23
use std::sync::Arc;
34

4-
use libc::c_int;
5-
65
use crate::client::conn;
76
use crate::rt::Executor as _;
87

src/ffi/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use libc::size_t;
1+
use crate::ffi::size_t;
22

33
/// A more detailed error object returned by some hyper functions.
44
///

src/ffi/http_types.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
use std::ffi::{c_int, c_void};
2+
13
use bytes::Bytes;
2-
use libc::{c_int, size_t};
3-
use std::ffi::c_void;
44

55
use super::body::hyper_body;
66
use super::error::hyper_code;
77
use super::task::{hyper_task_return_type, AsTaskType};
88
use super::{UserDataPointer, HYPER_ITER_CONTINUE};
99
use crate::body::Incoming as IncomingBody;
1010
use crate::ext::{HeaderCaseMap, OriginalHeaderOrder, ReasonPhrase};
11+
use crate::ffi::size_t;
1112
use crate::header::{HeaderName, HeaderValue};
1213
use crate::{HeaderMap, Method, Request, Response, Uri};
1314

src/ffi/io.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use std::ffi::c_void;
22
use std::pin::Pin;
33
use std::task::{Context, Poll};
44

5-
use crate::rt::{Read, Write};
6-
use libc::size_t;
7-
85
use super::task::hyper_context;
6+
use crate::ffi::size_t;
7+
use crate::rt::{Read, Write};
98

109
/// Sentinel value to return from a read or write callback that the operation
1110
/// is pending.

src/ffi/mod.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ pub use self::io::*;
6262
pub use self::task::*;
6363

6464
/// Return in iter functions to continue iterating.
65-
pub const HYPER_ITER_CONTINUE: libc::c_int = 0;
65+
pub const HYPER_ITER_CONTINUE: std::ffi::c_int = 0;
6666
/// Return in iter functions to stop iterating.
6767
#[allow(unused)]
68-
pub const HYPER_ITER_BREAK: libc::c_int = 1;
68+
pub const HYPER_ITER_BREAK: std::ffi::c_int = 1;
6969

7070
/// An HTTP Version that is unspecified.
71-
pub const HYPER_HTTP_VERSION_NONE: libc::c_int = 0;
71+
pub const HYPER_HTTP_VERSION_NONE: std::ffi::c_int = 0;
7272
/// The HTTP/1.0 version.
73-
pub const HYPER_HTTP_VERSION_1_0: libc::c_int = 10;
73+
pub const HYPER_HTTP_VERSION_1_0: std::ffi::c_int = 10;
7474
/// The HTTP/1.1 version.
75-
pub const HYPER_HTTP_VERSION_1_1: libc::c_int = 11;
75+
pub const HYPER_HTTP_VERSION_1_1: std::ffi::c_int = 11;
7676
/// The HTTP/2 version.
77-
pub const HYPER_HTTP_VERSION_2: libc::c_int = 20;
77+
pub const HYPER_HTTP_VERSION_2: std::ffi::c_int = 20;
7878

7979
#[derive(Clone)]
8080
struct UserDataPointer(*mut std::ffi::c_void);
@@ -87,9 +87,13 @@ unsafe impl Sync for UserDataPointer {}
8787
/// cbindgen:ignore
8888
static VERSION_CSTR: &str = concat!(env!("CARGO_PKG_VERSION"), "\0");
8989

90+
// `core::ffi::c_size_t` is a nightly-only experimental API.
91+
// https://github.com/rust-lang/rust/issues/88345
92+
type size_t = usize;
93+
9094
ffi_fn! {
9195
/// Returns a static ASCII (null terminated) string of the hyper version.
92-
fn hyper_version() -> *const libc::c_char {
96+
fn hyper_version() -> *const std::ffi::c_char {
9397
VERSION_CSTR.as_ptr() as _
9498
} ?= std::ptr::null()
9599
}

src/ffi/task.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::c_void;
1+
use std::ffi::{c_int, c_void};
22
use std::future::Future;
33
use std::pin::Pin;
44
use std::ptr;
@@ -9,7 +9,6 @@ use std::sync::{
99
use std::task::{Context, Poll};
1010

1111
use futures_util::stream::{FuturesUnordered, Stream};
12-
use libc::c_int;
1312

1413
use super::error::hyper_code;
1514
use super::UserDataPointer;

0 commit comments

Comments
 (0)