File: newer-async-io

package info (click to toggle)
rust-sqlx-core 0.8.3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 976 kB
  • sloc: makefile: 2
file content (85 lines) | stat: -rw-r--r-- 2,762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Index: sqlx-core/Cargo.toml
===================================================================
--- sqlx-core.orig/Cargo.toml
+++ sqlx-core/Cargo.toml
@@ -27,7 +27,7 @@ repository = "https://github.com/launchb
 features = ["offline"]
 
 [dependencies.async-io]
-version = "1.9.0"
+version = ">= 1.9.0"
 optional = true
 
 [dependencies.async-std]
Index: sqlx-core/src/lib.rs
===================================================================
--- sqlx-core.orig/src/lib.rs
+++ sqlx-core/src/lib.rs
@@ -17,7 +17,7 @@
 #![allow(clippy::needless_doctest_main, clippy::type_complexity)]
 // The only unsafe code in SQLx is that necessary to interact with native APIs like with SQLite,
 // and that can live in its own separate driver crate.
-#![forbid(unsafe_code)]
+//#![forbid(unsafe_code)] disabled due to async-io update.
 // Allows an API be documented as only available in some specific platforms.
 // <https://doc.rust-lang.org/unstable-book/language-features/doc-cfg.html>
 #![cfg_attr(docsrs, feature(doc_cfg))]
Index: sqlx-core/src/rt/rt_async_std/socket.rs
===================================================================
--- sqlx-core.orig/src/rt/rt_async_std/socket.rs
+++ sqlx-core/src/rt/rt_async_std/socket.rs
@@ -11,11 +11,15 @@ use async_io::Async;
 
 impl Socket for Async<TcpStream> {
     fn try_read(&mut self, buf: &mut dyn ReadBuf) -> io::Result<usize> {
+      unsafe {
         self.get_mut().read(buf.init_mut())
+      }
     }
 
     fn try_write(&mut self, buf: &[u8]) -> io::Result<usize> {
+      unsafe {
         self.get_mut().write(buf)
+      }
     }
 
     fn poll_read_ready(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
@@ -27,18 +31,24 @@ impl Socket for Async<TcpStream> {
     }
 
     fn poll_shutdown(&mut self, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
+      unsafe {
         Poll::Ready(self.get_mut().shutdown(Shutdown::Both))
+      }
     }
 }
 
 #[cfg(unix)]
 impl Socket for Async<std::os::unix::net::UnixStream> {
     fn try_read(&mut self, buf: &mut dyn ReadBuf) -> io::Result<usize> {
+      unsafe {
         self.get_mut().read(buf.init_mut())
+      }
     }
 
     fn try_write(&mut self, buf: &[u8]) -> io::Result<usize> {
+      unsafe {
         self.get_mut().write(buf)
+      }
     }
 
     fn poll_read_ready(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
@@ -46,10 +56,12 @@ impl Socket for Async<std::os::unix::net
     }
 
     fn poll_write_ready(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
-        self.poll_writable(cx)
+      self.poll_writable(cx)
     }
 
     fn poll_shutdown(&mut self, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
+      unsafe {
         Poll::Ready(self.get_mut().shutdown(Shutdown::Both))
+      }
     }
 }