Skip to content

Commit

Permalink
rename files, change microsoft target to msvc instead of gnu
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Ignacio Biehl authored and Jose Ignacio Biehl committed Jan 5, 2024
1 parent 3c82e50 commit e617772
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain nightly --default-host x86_64-pc-windows-gnu
- rustup-init -yv --default-toolchain nightly --default-host x86_64-pc-windows-msvc
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -vV
- cargo -vV
Expand Down
4 changes: 2 additions & 2 deletions benches/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern crate test;

use std::net::SocketAddr;

use coap::{server::UdpCoapListener, Server, UDPCoAPClient};
use coap::{server::UdpCoapListener, Server, UdpCoAPClient};
use coap_lite::{CoapOption, CoapRequest, MessageType};
use tokio::{net::UdpSocket, runtime::Runtime};

Expand Down Expand Up @@ -38,7 +38,7 @@ fn bench_server_with_request(b: &mut test::Bencher) {

let server_port = rx.blocking_recv().unwrap();
let client = rt.block_on(async {
UDPCoAPClient::new_udp(format!("127.0.0.1:{}", server_port))
UdpCoAPClient::new_udp(format!("127.0.0.1:{}", server_port))
.await
.unwrap()
});
Expand Down
12 changes: 6 additions & 6 deletions examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate coap;

use coap::UDPCoAPClient;
use coap::UdpCoAPClient;
use std::io;
use std::io::ErrorKind;

Expand All @@ -26,7 +26,7 @@ async fn example_get() {
let url = "coap://127.0.0.1:5683/hello/get";
println!("Client request: {}", url);

match UDPCoAPClient::get(url).await {
match UdpCoAPClient::get(url).await {
Ok(response) => {
println!(
"Server reply: {}",
Expand All @@ -48,7 +48,7 @@ async fn example_post() {
let data = b"data".to_vec();
println!("Client request: {}", url);

match UDPCoAPClient::post(url, data).await {
match UdpCoAPClient::post(url, data).await {
Ok(response) => {
println!(
"Server reply: {}",
Expand All @@ -70,7 +70,7 @@ async fn example_put() {
let data = b"data".to_vec();
println!("Client request: {}", url);

match UDPCoAPClient::put(url, data).await {
match UdpCoAPClient::put(url, data).await {
Ok(response) => {
println!(
"Server reply: {}",
Expand All @@ -91,7 +91,7 @@ async fn example_delete() {
let url = "coap://127.0.0.1:5683/hello/delete";
println!("Client request: {}", url);

match UDPCoAPClient::delete(url).await {
match UdpCoAPClient::delete(url).await {
Ok(response) => {
println!(
"Server reply: {}",
Expand All @@ -109,7 +109,7 @@ async fn example_delete() {
}

async fn example_observe() {
let client = UDPCoAPClient::new_udp("127.0.0.1:5683").await.unwrap();
let client = UdpCoAPClient::new_udp("127.0.0.1:5683").await.unwrap();
client
.observe("/hello/put", |msg| {
println!(
Expand Down
4 changes: 2 additions & 2 deletions examples/dtls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// a look at the test in dtls.rs
extern crate coap;
use coap::client::CoAPClient;
use coap::dtls::DTLSConfig;
use coap::dtls::DtlsConfig;
use coap::Server;
use coap_lite::{CoapRequest, RequestType as Method};
use std::future::Future;
Expand Down Expand Up @@ -59,7 +59,7 @@ async fn main() {
.await
.unwrap();

let dtls_config = DTLSConfig {
let dtls_config = DtlsConfig {
config,
dest_addr: ("127.0.0.1", server_port)
.to_socket_addrs()
Expand Down
4 changes: 2 additions & 2 deletions examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate coap;

use std::net::SocketAddr;

use coap::{Server, UDPCoAPClient};
use coap::{Server, UdpCoAPClient};
use coap_lite::CoapRequest;
#[tokio::main]
async fn main() {
Expand All @@ -28,7 +28,7 @@ async fn main() {
println!("Client request: {}", url);

// Maybe need sleep seconds before start client on some OS: https://github.com/Covertness/coap-rs/issues/75
let response = UDPCoAPClient::get(url).await.unwrap();
let response = UdpCoAPClient::get(url).await.unwrap();
println!(
"Server reply: {}",
String::from_utf8(response.message.payload).unwrap()
Expand Down
76 changes: 38 additions & 38 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "dtls")]
use crate::dtls::{DTLSConfig, DTLSConnection};
use crate::dtls::{DtlsConfig, DtlsConnection};
use alloc::string::String;
use alloc::vec::Vec;
use coap_lite::{
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Transport for UdpTransport {
}

/// A CoAP client over UDP. This client can send multicast and broadcasts
pub type UDPCoAPClient = CoAPClient<UdpTransport>;
pub type UdpCoAPClient = CoAPClient<UdpTransport>;

pub struct CoAPClient<T: Transport> {
transport: T,
Expand All @@ -63,7 +63,7 @@ pub struct CoAPClient<T: Transport> {
read_timeout: Option<Duration>,
}

impl UDPCoAPClient {
impl UdpCoAPClient {
pub async fn new_with_specific_source<A: ToSocketAddrs, B: ToSocketAddrs>(
bind_addr: A,
peer_addr: B,
Expand All @@ -74,7 +74,7 @@ impl UDPCoAPClient {
))?;
let socket = UdpSocket::bind(bind_addr).await?;
let transport = UdpTransport { socket, peer_addr };
return Ok(UDPCoAPClient::from_transport(transport));
return Ok(UdpCoAPClient::from_transport(transport));
}

pub async fn new_udp<A: ToSocketAddrs>(addr: A) -> Result<Self> {
Expand Down Expand Up @@ -137,10 +137,10 @@ impl UDPCoAPClient {
}

#[cfg(feature = "dtls")]
impl CoAPClient<DTLSConnection> {
pub async fn from_dtls_config(config: DTLSConfig) -> Result<Self> {
impl CoAPClient<DtlsConnection> {
pub async fn from_dtls_config(config: DtlsConfig) -> Result<Self> {
Ok(CoAPClient::from_transport(
DTLSConnection::try_new(config).await?,
DtlsConnection::try_new(config).await?,
))
}
}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<T: Transport> CoAPClient<T> {
/// Execute a single request (GET, POST, PUT, DELETE) with a coap url using udp
pub async fn request(url: &str, method: Method, data: Option<Vec<u8>>) -> Result<CoapResponse> {
let (domain, port, path, queries) = Self::parse_coap_url(url)?;
let mut client = UDPCoAPClient::new_udp((domain.as_str(), port)).await?;
let mut client = UdpCoAPClient::new_udp((domain.as_str(), port)).await?;
client
.request_path(&path, method, data, queries, Some(domain))
.await
Expand All @@ -224,7 +224,7 @@ impl<T: Transport> CoAPClient<T> {
timeout: Duration,
) -> Result<CoapResponse> {
let (domain, port, path, queries) = Self::parse_coap_url(url)?;
let mut client = UDPCoAPClient::new_udp((domain.as_str(), port)).await?;
let mut client = UdpCoAPClient::new_udp((domain.as_str(), port)).await?;
client
.request_path_with_timeout(&path, method, data, queries, Some(domain), timeout)
.await
Expand Down Expand Up @@ -644,21 +644,21 @@ mod test {
use std::time::Duration;
#[test]
fn test_parse_coap_url_good_url() {
assert!(UDPCoAPClient::parse_coap_url("coap://127.0.0.1").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://127.0.0.1:5683").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://[::1]").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://[::1]:5683").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://[bbbb::9329:f033:f558:7418]").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://[bbbb::9329:f033:f558:7418]:5683").is_ok());
assert!(UDPCoAPClient::parse_coap_url("coap://127.0.0.1/?hello=world").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://127.0.0.1").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://127.0.0.1:5683").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://[::1]").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://[::1]:5683").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://[bbbb::9329:f033:f558:7418]").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://[bbbb::9329:f033:f558:7418]:5683").is_ok());
assert!(UdpCoAPClient::parse_coap_url("coap://127.0.0.1/?hello=world").is_ok());
}

#[test]
fn test_parse_coap_url_bad_url() {
assert!(UDPCoAPClient::parse_coap_url("coap://127.0.0.1:65536").is_err());
assert!(UDPCoAPClient::parse_coap_url("coap://").is_err());
assert!(UDPCoAPClient::parse_coap_url("coap://:5683").is_err());
assert!(UDPCoAPClient::parse_coap_url("127.0.0.1").is_err());
assert!(UdpCoAPClient::parse_coap_url("coap://127.0.0.1:65536").is_err());
assert!(UdpCoAPClient::parse_coap_url("coap://").is_err());
assert!(UdpCoAPClient::parse_coap_url("coap://:5683").is_err());
assert!(UdpCoAPClient::parse_coap_url("127.0.0.1").is_err());
}

async fn request_handler(req: Box<CoapRequest<SocketAddr>>) -> Box<CoapRequest<SocketAddr>> {
Expand All @@ -669,7 +669,7 @@ mod test {
#[test]
fn test_parse_queries() {
if let Ok((_, _, _, Some(queries))) =
UDPCoAPClient::parse_coap_url("coap://127.0.0.1/?hello=world&test1=test2")
UdpCoAPClient::parse_coap_url("coap://127.0.0.1/?hello=world&test1=test2")
{
assert_eq!("hello=world&test1=test2".as_bytes().to_vec(), queries);
} else {
Expand All @@ -679,7 +679,7 @@ mod test {

#[tokio::test]
async fn test_get_url() {
let resp = UDPCoAPClient::get("coap://coap.me:5683/hello")
let resp = UdpCoAPClient::get("coap://coap.me:5683/hello")
.await
.unwrap();
assert_eq!(resp.message.payload, b"world".to_vec());
Expand All @@ -692,7 +692,7 @@ mod test {
.await
.unwrap();

let error = UDPCoAPClient::get_with_timeout(
let error = UdpCoAPClient::get_with_timeout(
&format!("coap://127.0.0.1:{}/Rust", server_port),
Duration::new(0, 0),
)
Expand All @@ -704,7 +704,7 @@ mod test {
#[tokio::test]
async fn test_get() {
let domain = "coap.me";
let mut client = UDPCoAPClient::new_udp((domain, 5683)).await.unwrap();
let mut client = UdpCoAPClient::new_udp((domain, 5683)).await.unwrap();
let resp = client
.request_path("/hello", Method::Get, None, None, Some(domain.to_string()))
.await
Expand All @@ -713,11 +713,11 @@ mod test {
}
#[tokio::test]
async fn test_post_url() {
let resp = UDPCoAPClient::post("coap://coap.me:5683/validate", b"world".to_vec())
let resp = UdpCoAPClient::post("coap://coap.me:5683/validate", b"world".to_vec())
.await
.unwrap();
assert_eq!(resp.message.payload, b"POST OK".to_vec());
let resp = UDPCoAPClient::post("coap://coap.me:5683/validate", b"test".to_vec())
let resp = UdpCoAPClient::post("coap://coap.me:5683/validate", b"test".to_vec())
.await
.unwrap();
assert_eq!(resp.message.payload, b"POST OK".to_vec());
Expand All @@ -726,7 +726,7 @@ mod test {
#[tokio::test]
async fn test_post() {
let domain = "coap.me";
let mut client = UDPCoAPClient::new_udp((domain, 5683)).await.unwrap();
let mut client = UdpCoAPClient::new_udp((domain, 5683)).await.unwrap();
let resp = client
.request_path(
"/validate",
Expand All @@ -742,11 +742,11 @@ mod test {

#[tokio::test]
async fn test_put_url() {
let resp = UDPCoAPClient::put("coap://coap.me:5683/create1", b"world".to_vec())
let resp = UdpCoAPClient::put("coap://coap.me:5683/create1", b"world".to_vec())
.await
.unwrap();
assert_eq!(resp.message.payload, b"Created".to_vec());
let resp = UDPCoAPClient::put("coap://coap.me:5683/create1", b"test".to_vec())
let resp = UdpCoAPClient::put("coap://coap.me:5683/create1", b"test".to_vec())
.await
.unwrap();
assert_eq!(resp.message.payload, b"Created".to_vec());
Expand All @@ -755,7 +755,7 @@ mod test {
#[tokio::test]
async fn test_put() {
let domain = "coap.me";
let mut client = UDPCoAPClient::new_udp((domain, 5683)).await.unwrap();
let mut client = UdpCoAPClient::new_udp((domain, 5683)).await.unwrap();
let resp = client
.request_path(
"/create1",
Expand All @@ -771,11 +771,11 @@ mod test {

#[tokio::test]
async fn test_delete_url() {
let resp = UDPCoAPClient::delete("coap://coap.me:5683/validate")
let resp = UdpCoAPClient::delete("coap://coap.me:5683/validate")
.await
.unwrap();
assert_eq!(resp.message.payload, b"DELETE OK".to_vec());
let resp = UDPCoAPClient::delete("coap://coap.me:5683/validate")
let resp = UdpCoAPClient::delete("coap://coap.me:5683/validate")
.await
.unwrap();
assert_eq!(resp.message.payload, b"DELETE OK".to_vec());
Expand All @@ -784,7 +784,7 @@ mod test {
#[tokio::test]
async fn test_delete() {
let domain = "coap.me";
let mut client = UDPCoAPClient::new_udp((domain, 5683)).await.unwrap();
let mut client = UdpCoAPClient::new_udp((domain, 5683)).await.unwrap();
let resp = client
.request_path(
"/validate",
Expand All @@ -800,15 +800,15 @@ mod test {

#[tokio::test]
async fn test_set_broadcast() {
let client = UDPCoAPClient::new_udp(("127.0.0.1", 5683)).await.unwrap();
let client = UdpCoAPClient::new_udp(("127.0.0.1", 5683)).await.unwrap();
assert!(client.set_broadcast(true).is_ok());
assert!(client.set_broadcast(false).is_ok());
}

#[tokio::test]
#[ignore]
async fn test_set_broadcast_v6() {
let client = UDPCoAPClient::new_udp(("::1", 5683)).await.unwrap();
let client = UdpCoAPClient::new_udp(("::1", 5683)).await.unwrap();
assert!(client.set_broadcast(true).is_ok());
assert!(client.set_broadcast(false).is_ok());
}
Expand All @@ -825,7 +825,7 @@ mod test {
.set_type(coap_lite::MessageType::NonConfirmable);
request.message.payload = b"Discovery".to_vec();

let client = UDPCoAPClient::new_udp(("127.0.0.1", 5683)).await.unwrap();
let client = UdpCoAPClient::new_udp(("127.0.0.1", 5683)).await.unwrap();
client.send_all_coap(&request, 0).await.unwrap();
}
#[tokio::test]
Expand All @@ -841,7 +841,7 @@ mod test {
large_payload.extend_from_slice(PAYLOAD_STR.as_bytes());
}
let domain = "coap.me";
let mut client = UDPCoAPClient::new_udp((domain, 5683)).await.unwrap();
let mut client = UdpCoAPClient::new_udp((domain, 5683)).await.unwrap();
let resp = client
.request_path(
"/large-create",
Expand Down Expand Up @@ -881,7 +881,7 @@ mod test {
.set_type(coap_lite::MessageType::NonConfirmable);
request.message.payload = b"Discovery".to_vec();

let client = UDPCoAPClient::new_udp(("::1", 5683)).await.unwrap();
let client = UdpCoAPClient::new_udp(("::1", 5683)).await.unwrap();
client.send_all_coap(&request, 0x4).await.unwrap();
}
}
Loading

0 comments on commit e617772

Please sign in to comment.