Skip to content

Commit c3729ff

Browse files
committed
Nightly Format and Windows compile fix
1 parent cf6ff29 commit c3729ff

File tree

8 files changed

+34
-73
lines changed

8 files changed

+34
-73
lines changed

src/android/l2cap_channel.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
use std::{
2-
fmt,
3-
io::Result,
4-
pin::Pin,
5-
slice,
6-
task::{Context, Poll},
7-
thread,
8-
};
1+
use std::io::Result;
2+
use std::pin::Pin;
3+
use std::task::{Context, Poll};
4+
use std::{fmt, slice, thread};
95

106
use java_spaghetti::{ByteArray, Global, Local, PrimitiveArray};
117
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, DuplexStream, ReadBuf};

src/bluer/l2cap_channel.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use std::{
2-
io::Result,
3-
pin::Pin,
4-
task::{Context, Poll},
5-
};
1+
use std::io::Result;
2+
use std::pin::Pin;
3+
use std::task::{Context, Poll};
64

75
use bluer::l2cap::{SocketAddr, Stream};
86
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

src/corebluetooth/device.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ use objc_foundation::{INSArray, INSFastEnumeration, INSString, NSArray};
66
use objc_id::ShareId;
77

88
use super::delegates::{PeripheralDelegate, PeripheralEvent};
9+
#[cfg(feature = "l2cap")]
10+
use super::l2cap_channel::Channel;
911
use super::types::{CBPeripheral, CBPeripheralState, CBService, CBUUID};
1012
use crate::device::ServicesChanged;
1113
use crate::error::ErrorKind;
1214
use crate::pairing::PairingAgent;
1315
use crate::{Device, DeviceId, Error, Result, Service, Uuid};
1416

15-
#[cfg(feature = "l2cap")]
16-
use super::l2cap_channel::Channel;
17-
1817
/// A Bluetooth LE device
1918
#[derive(Clone)]
2019
pub struct DeviceImpl {

src/corebluetooth/l2cap_channel.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
use std::{
2-
io::Result,
3-
os::fd::{FromRawFd, RawFd},
4-
pin::Pin,
5-
task::{Context, Poll},
6-
};
1+
use std::io::Result;
2+
use std::os::fd::{FromRawFd, RawFd};
3+
use std::pin::Pin;
4+
use std::task::{Context, Poll};
75

86
use objc_foundation::INSData;
97
use objc_id::{Id, Shared};
10-
use tokio::{
11-
io::{AsyncRead, AsyncWrite, ReadBuf},
12-
net::UnixStream,
13-
};
8+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
9+
use tokio::net::UnixStream;
1410

1511
use super::types::{kCFStreamPropertySocketNativeHandle, CBL2CAPChannel, CFStream};
16-
use crate::{error::ErrorKind, Error};
12+
use crate::error::ErrorKind;
13+
use crate::Error;
1714

1815
// This implementation is based upon the fact that that CBL2CAPChannel::outputStream -> an NS Output Stream; (https://developer.apple.com/documentation/foundation/outputstream)
1916
// NS Output stream is toll free bridged to CFWriteStream (https://developer.apple.com/documentation/corefoundation/cfwritestream)

src/device.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use futures_core::Stream;
44
use futures_lite::StreamExt;
55

66
use crate::error::ErrorKind;
7-
use crate::pairing::PairingAgent;
8-
use crate::{sys, DeviceId, Error, Result, Service, Uuid};
9-
107
#[cfg(feature = "l2cap")]
118
use crate::l2cap_channel::L2capChannel;
9+
use crate::pairing::PairingAgent;
10+
use crate::{sys, DeviceId, Error, Result, Service, Uuid};
1211

1312
/// A Bluetooth LE device
1413
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

src/l2cap_channel.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use std::{
2-
io::Result,
3-
pin::Pin,
4-
task::{Context, Poll},
5-
};
1+
use std::io::Result;
2+
use std::pin::Pin;
3+
use std::task::{Context, Poll};
64

75
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
86

src/windows/device.rs

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ impl DeviceImpl {
273273
Err(ErrorKind::NotSupported.into())
274274
}
275275

276+
#[cfg(feature = "l2cap")]
276277
pub async fn open_l2cap_channel(
277278
&self,
278279
_psm: u16,

src/windows/l2cap_channel.rs

+11-38
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,24 @@ use std::fmt;
22

33
use crate::Result;
44

5-
pub struct L2capChannelReader {
6-
_private: (),
7-
}
8-
9-
impl L2capChannelReader {
10-
#[inline]
11-
pub async fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
12-
todo!()
13-
}
5+
pub struct Channel {}
146

15-
pub fn try_read(&mut self, _buf: &mut [u8]) -> Result<usize> {
16-
todo!()
17-
}
18-
19-
pub async fn close(&mut self) -> Result<()> {
20-
todo!()
7+
impl AsyncRead for Channel {
8+
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<std::io::Result<()>> {
9+
unimplemented!()
2110
}
2211
}
2312

24-
impl fmt::Debug for L2capChannelReader {
25-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26-
f.write_str("L2capChannelReader")
13+
impl AsyncWrite for Channel {
14+
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> {
15+
unimplemented!()
2716
}
28-
}
2917

30-
pub struct L2capChannelWriter {
31-
_private: (),
32-
}
33-
34-
impl L2capChannelWriter {
35-
pub async fn write(&mut self, _packet: &[u8]) -> Result<()> {
36-
todo!()
37-
}
38-
39-
pub fn try_write(&mut self, _packet: &[u8]) -> Result<()> {
40-
todo!()
18+
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
19+
unimplemented!()
4120
}
4221

43-
pub async fn close(&mut self) -> Result<()> {
44-
todo!()
45-
}
46-
}
47-
48-
impl fmt::Debug for L2capChannelWriter {
49-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50-
f.write_str("L2capChannelWriter")
22+
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
23+
unimplemented!()
5124
}
5225
}

0 commit comments

Comments
 (0)