| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::{Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#}; |
| 6 | |
| 7 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::BufMutrust-analyzer cargo bytes 1.12.1 buf/buf_mut/BufMut#; |
| 8 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!; |
| 9 | |
| 10 | pub use bufferedrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/::{BufferedSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/BufferedSocket#, WriteBufferrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/WriteBuffer#}; |
| 11 | |
| 12 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::iorust-analyzer cargo sqlx-core 0.8.3 io/::ReadBufrust-analyzer cargo sqlx-core 0.8.3 io/read_buf/ReadBuf#; |
| 13 | |
| 14 | mod bufferedrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/; |
| 15 | |
| 16 | pub trait Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin# + 'static { |
| 17 | fn try_readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_read().(&mut self, buf: &mut dyn ReadBufrust-analyzer cargo sqlx-core 0.8.3 io/read_buf/ReadBuf#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>; |
| 18 | |
| 19 | fn try_writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_write().(&mut self, buf: &[u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>; |
| 20 | |
| 21 | fn poll_read_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_read_ready().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>>; |
| 22 | |
| 23 | fn poll_write_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_write_ready().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>>; |
| 24 | |
| 25 | fn poll_flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_flush().(&mut self, _cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 26 | // `flush()` is a no-op for TCP/UDS |
| 27 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())) |
| 28 | } |
| 29 | |
| 30 | fn poll_shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_shutdown().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>>; |
| 31 | |
| 32 | fn readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#read().<'a, B: ReadBufrust-analyzer cargo sqlx-core 0.8.3 io/read_buf/ReadBuf#>(&'a mut self, buf: &'a mut B) -> Readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#<'a, Self, B> |
| 33 | where |
| 34 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 35 | { |
| 36 | Readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read# { socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#socket.: self, bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#buf. } |
| 37 | } |
| 38 | |
| 39 | fn writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#write().<'a>(&'a mut self, buf: &'a [u8]) -> Writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#<'a, Self> |
| 40 | where |
| 41 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 42 | { |
| 43 | Writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Write# { socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#socket.: self, bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#buf. } |
| 44 | } |
| 45 | |
| 46 | fn flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#flush().(&mut self) -> Flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#<'_, Self> |
| 47 | where |
| 48 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 49 | { |
| 50 | Flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush# { socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#socket.: self } |
| 51 | } |
| 52 | |
| 53 | fn shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#shutdown().(&mut self) -> Shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#<'_, Self> |
| 54 | where |
| 55 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 56 | { |
| 57 | Shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown# { socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#socket.: self } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | pub struct Readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, B> { |
| 62 | socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#socket.: &'a mut S, |
| 63 | bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#buf.: &'a mut B, |
| 64 | } |
| 65 | |
| 66 | impl<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, B> Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#<'a, S, B> |
| 67 | where |
| 68 | S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#, |
| 69 | B: ReadBufrust-analyzer cargo sqlx-core 0.8.3 io/read_buf/ReadBuf#, |
| 70 | { |
| 71 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Read<'a, S, B>`][Future]Output# = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>; |
| 72 | |
| 73 | fn pollrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Read<'a, S, B>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Read<'a, S, B>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Read<'a, S, B>`][Future]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output#> { |
| 74 | let this = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self; |
| 75 | |
| 76 | while this.bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#buf..has_remaining_mutrust-analyzer cargo bytes 1.12.1 buf/buf_mut/BufMut#has_remaining_mut().() { |
| 77 | match this.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#socket..try_readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_read().(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().this.bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#buf.) { |
| 78 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => { |
| 79 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(this.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Read#socket..poll_read_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_read_ready().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 80 | } |
| 81 | ready => return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(ready), |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | pub struct Writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> { |
| 90 | socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#socket.: &'a mut S, |
| 91 | bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#buf.: &'a [u8], |
| 92 | } |
| 93 | |
| 94 | impl<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#<'a, S> |
| 95 | where |
| 96 | S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#, |
| 97 | { |
| 98 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Write<'a, S>`][Future]Output# = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>; |
| 99 | |
| 100 | fn pollrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Write<'a, S>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Write<'a, S>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Write<'a, S>`][Future]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output#> { |
| 101 | let this = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self; |
| 102 | |
| 103 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#buf..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 104 | match this.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#socket..try_writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_write().(this.bufrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#buf.) { |
| 105 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => { |
| 106 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(this.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Write#socket..poll_write_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_write_ready().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 107 | } |
| 108 | ready => return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(ready), |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | pub struct Flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> { |
| 117 | socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#socket.: &'a mut S, |
| 118 | } |
| 119 | |
| 120 | impl<'a, S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#<'a, S> { |
| 121 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Flush<'a, S>`][Future]Output# = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>; |
| 122 | |
| 123 | fn pollrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Flush<'a, S>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Flush<'a, S>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Flush<'a, S>`][Future]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output#> { |
| 124 | self.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Flush#socket..poll_flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_flush().(cx) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | pub struct Shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> { |
| 129 | socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#socket.: &'a mut S, |
| 130 | } |
| 131 | |
| 132 | impl<'a, S: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#<'a, S> |
| 133 | where |
| 134 | S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#, |
| 135 | { |
| 136 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Shutdown<'a, S>`][Future]Output# = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>; |
| 137 | |
| 138 | fn pollrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Shutdown<'a, S>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Shutdown<'a, S>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Shutdown<'a, S>`][Future]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output#> { |
| 139 | self.socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Shutdown#socket..poll_shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_shutdown().(cx) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | pub trait WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket# { |
| 144 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output#; |
| 145 | |
| 146 | fn with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#with_socket().<S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#>( |
| 147 | self, |
| 148 | socket: S, |
| 149 | ) -> impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output# = Self::Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output#> + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#; |
| 150 | } |
| 151 | |
| 152 | pub struct SocketIntoBoxrust-analyzer cargo sqlx-core 0.8.3 net/socket/SocketIntoBox#; |
| 153 | |
| 154 | impl WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket# for SocketIntoBoxrust-analyzer cargo sqlx-core 0.8.3 net/socket/SocketIntoBox# { |
| 155 | type Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[SocketIntoBox][WithSocket]Output# = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#>; |
| 156 | |
| 157 | async fn with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[SocketIntoBox][WithSocket]with_socket().<S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#>(self, socket: S) -> Selfrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[SocketIntoBox][WithSocket]::Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output# { |
| 158 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(socket) |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | impl<S: Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> Socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<S> { |
| 163 | fn try_readrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]try_read().(&mut self, buf: &mut dyn ReadBufrust-analyzer cargo sqlx-core 0.8.3 io/read_buf/ReadBuf#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 164 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).try_readrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_read().(buf) |
| 165 | } |
| 166 | |
| 167 | fn try_writerust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]try_write().(&mut self, buf: &[u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 168 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).try_writerust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#try_write().(buf) |
| 169 | } |
| 170 | |
| 171 | fn poll_read_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]poll_read_ready().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 172 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).poll_read_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_read_ready().(cx) |
| 173 | } |
| 174 | |
| 175 | fn poll_write_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]poll_write_ready().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 176 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).poll_write_readyrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_write_ready().(cx) |
| 177 | } |
| 178 | |
| 179 | fn poll_flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]poll_flush().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 180 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).poll_flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_flush().(cx) |
| 181 | } |
| 182 | |
| 183 | fn poll_shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/impl#[`Box<S>`][Socket]poll_shutdown().(&mut self, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 184 | (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self).poll_shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/Socket#poll_shutdown().(cx) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | pub async fn connect_tcprust-analyzer cargo sqlx-core 0.8.3 net/socket/connect_tcp().<Ws: WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#>( |
| 189 | host: &str, |
| 190 | port: u16, |
| 191 | with_socket: Ws, |
| 192 | ) -> craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<Ws::Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output#> { |
| 193 | // IPv6 addresses in URLs will be wrapped in brackets and the `url` crate doesn't trim those. |
| 194 | let host = host.trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().(&['[', ']'][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 195 | |
| 196 | #[cfg(feature = "_rt-tokio")] |
| 197 | if craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::rt_tokiorust-analyzer cargo sqlx-core 0.8.3 rt/rt_tokio/::availablerust-analyzer cargo sqlx-core 0.8.3 rt/rt_tokio/available().() { |
| 198 | use tokiorust-analyzer cargo tokio 1.53.1 crate/::netrust-analyzer cargo tokio 1.53.1 net/::TcpStreamrust-analyzer cargo tokio 1.53.1 net/tcp/stream/TcpStream#; |
| 199 | |
| 200 | let stream = TcpStreamrust-analyzer cargo tokio 1.53.1 net/tcp/stream/TcpStream#::connectrust-analyzer cargo tokio 1.53.1 net/tcp/stream/impl#[TcpStream]connect().((host, port)).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 201 | stream.set_nodelayrust-analyzer cargo tokio 1.53.1 net/tcp/stream/impl#[TcpStream]set_nodelay().(true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 202 | |
| 203 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(with_socket.with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#with_socket().(stream).await); |
| 204 | } |
| 205 | |
| 206 | #[cfg(feature = "_rt-async-std")] |
| 207 | { |
| 208 | use async_iorust-analyzer cargo async-io 2.6.0 crate/::Asyncrust-analyzer cargo async-io 2.6.0 Async#; |
| 209 | use async_stdrust-analyzer cargo async-std 1.13.2 crate/::netrust-analyzer cargo async-std 1.13.2 net/::ToSocketAddrsrust-analyzer cargo async-std 1.13.2 net/addr/ToSocketAddrs#; |
| 210 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::TcpStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/tcp/TcpStream#; |
| 211 | |
| 212 | let mut last_err = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 213 | |
| 214 | // Loop through all the Socket Addresses that the hostname resolves to |
| 215 | for socket_addr in (host, port).to_socket_addrsrust-analyzer cargo async-std 1.13.2 net/addr/impl#[`(&str, u16)`][ToSocketAddrs]to_socket_addrs().().rust-analyzer cargo async-std 1.13.2 net/addr/impl#[`ToSocketAddrsFuture<I>`][Future]poll().awaitrust-analyzer cargo async-std 1.13.2 net/addr/impl#[`ToSocketAddrsFuture<I>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 216 | let stream = Asyncrust-analyzer cargo async-io 2.6.0 Async#::<TcpStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/tcp/TcpStream#>::connectrust-analyzer cargo async-io 2.6.0 impl#[`Async<TcpStream>`]connect().(socket_addr) |
| 217 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 218 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|s| { |
| 219 | s.get_refrust-analyzer cargo async-io 2.6.0 impl#[`Async<T>`]get_ref().().set_nodelayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/tcp/impl#[TcpStream]set_nodelay().(true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 220 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) |
| 221 | }); |
| 222 | match stream { |
| 223 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(stream) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(with_socket.with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#with_socket().(stream).await), |
| 224 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => last_err = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e), |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // If we reach this point, it means we failed to connect to any of the addresses. |
| 229 | // Return the last error we encountered, or a custom error if the hostname didn't resolve to any address. |
| 230 | match last_err { |
| 231 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(err) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 232 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().( |
| 233 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::AddrNotAvailablerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#AddrNotAvailable#, |
| 234 | "Hostname did not resolve to any addresses", |
| 235 | ) |
| 236 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | #[cfg(not(feature = "_rt-async-std"))] |
| 241 | { |
| 242 | craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::missing_rtrust-analyzer cargo sqlx-core 0.8.3 rt/missing_rt().((host, port, with_socket)) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /// Connect a Unix Domain Socket at the given path. |
| 247 | /// |
| 248 | /// Returns an error if Unix Domain Sockets are not supported on this platform. |
| 249 | pub async fn connect_udsrust-analyzer cargo sqlx-core 0.8.3 net/socket/connect_uds().<P: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, Ws: WithSocketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#>( |
| 250 | path: P, |
| 251 | with_socket: Ws, |
| 252 | ) -> craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<Ws::Outputrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#Output#> { |
| 253 | #[cfg(unix)] |
| 254 | { |
| 255 | #[cfg(feature = "_rt-tokio")] |
| 256 | if craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::rt_tokiorust-analyzer cargo sqlx-core 0.8.3 rt/rt_tokio/::availablerust-analyzer cargo sqlx-core 0.8.3 rt/rt_tokio/available().() { |
| 257 | use tokiorust-analyzer cargo tokio 1.53.1 crate/::netrust-analyzer cargo tokio 1.53.1 net/::UnixStreamrust-analyzer cargo tokio 1.53.1 net/unix/stream/UnixStream#; |
| 258 | |
| 259 | let stream = UnixStreamrust-analyzer cargo tokio 1.53.1 net/unix/stream/UnixStream#::connectrust-analyzer cargo tokio 1.53.1 net/unix/stream/impl#[UnixStream]connect().(path).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 260 | |
| 261 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(with_socket.with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#with_socket().(stream).await); |
| 262 | } |
| 263 | |
| 264 | #[cfg(feature = "_rt-async-std")] |
| 265 | { |
| 266 | use async_iorust-analyzer cargo async-io 2.6.0 crate/::Asyncrust-analyzer cargo async-io 2.6.0 Async#; |
| 267 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/::UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#; |
| 268 | |
| 269 | let stream = Asyncrust-analyzer cargo async-io 2.6.0 Async#::<UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#>::connectrust-analyzer cargo async-io 2.6.0 impl#[`Async<UnixStream>`]connect().(path).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 270 | |
| 271 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(with_socket.with_socketrust-analyzer cargo sqlx-core 0.8.3 net/socket/WithSocket#with_socket().(stream).await) |
| 272 | } |
| 273 | |
| 274 | #[cfg(not(feature = "_rt-async-std"))] |
| 275 | { |
| 276 | craterust-analyzer cargo sqlx-core 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::missing_rtrust-analyzer cargo sqlx-core 0.8.3 rt/missing_rt().((path, with_socket)) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | #[cfg(not(unix))] |
| 281 | { |
| 282 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().((path, with_socket)); |
| 283 | |
| 284 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::new( |
| 285 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Unsupportedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Unsupported#, |
| 286 | "Unix domain sockets are not supported on this platform", |
| 287 | ) |
| 288 | .into()) |
| 289 | } |
| 290 | } |