Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Commit 52fc6ea

Browse files
committed
Merge #89: Misc ergonomic improvements; release 0.14.1
184740e bump version to 0.14.1 (Andrew Poelstra) 1dc1528 simple_http: add support for replacing URL and path (Andrew Poelstra) d673b83 docs: document things correctly with feature gates (Andrew Poelstra) c25cdb7 Implement Client::from for Transports (Andrew Poelstra) Pull request description: Adds a couple utility functions and releases 0.14.1. ACKs for top commit: sanket1729: utACK 184740e Tree-SHA512: 9b3c3d2d275c8243df9a3bb26790314c461479fdb04d6948c1689619162956117b52909abec59b87ff103976d0e3bf774450533765413d2cba5b6d811350a207
2 parents 9710661 + 184740e commit 52fc6ea

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 0.14.1 - 2023-04-03
2+
3+
* simple_http: fix "re-open socket on write failure" behavior
4+
[#84](https://github.com/apoelstra/rust-jsonrpc/pull/84)
5+
[#86](https://github.com/apoelstra/rust-jsonrpc/pull/86)
6+
* simple_http: add "host" header (required by HTTP 1.1)
7+
[#85](https://github.com/apoelstra/rust-jsonrpc/pull/85)
8+
* simple_http: add ability to replace URL/path; minor ergonomic improvements
9+
[#89](https://github.com/apoelstra/rust-jsonrpc/pull/89)
10+
111
# 0.14.0 - 2022-11-28
212

313
This release significantly improves our `simple_http` client, though at the

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jsonrpc"
3-
version = "0.14.0"
3+
version = "0.14.1"
44
authors = ["Andrew Poelstra <[email protected]>"]
55
license = "CC0-1.0"
66
homepage = "https://github.com/apoelstra/rust-jsonrpc/"
@@ -11,6 +11,10 @@ keywords = [ "protocol", "json", "http", "jsonrpc" ]
1111
readme = "README.md"
1212
edition = "2018"
1313

14+
[package.metadata.docs.rs]
15+
all-features = true
16+
rustdoc-args = ["--cfg", "docsrs"]
17+
1418
[lib]
1519
name = "jsonrpc"
1620
path = "src/lib.rs"

src/client.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ impl fmt::Debug for crate::Client {
155155
}
156156
}
157157

158+
impl<T: Transport> From<T> for Client {
159+
fn from(t: T) -> Client {
160+
Client::with_transport(t)
161+
}
162+
}
163+
158164
#[cfg(test)]
159165
mod tests {
160166
use super::*;

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
//! Rust support for the JSON-RPC 2.0 protocol.
1818
//!
1919
20+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
21+
2022
// Coding conventions
21-
#![deny(non_upper_case_globals)]
22-
#![deny(non_camel_case_types)]
23-
#![deny(non_snake_case)]
24-
#![deny(unused_mut)]
2523
#![warn(missing_docs)]
2624

2725
use serde::{Deserialize, Serialize};

src/simple_http.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ impl SimpleHttpTransport {
119119
Builder::new()
120120
}
121121

122+
/// Replaces the URL of the transport
123+
pub fn set_url(&mut self, url: &str) -> Result<(), Error> {
124+
let url = check_url(url)?;
125+
self.addr = url.0;
126+
self.path = url.1;
127+
Ok(())
128+
}
129+
130+
/// Replaces only the path part of the URL
131+
pub fn set_url_path(&mut self, path: String) {
132+
self.path = path;
133+
}
134+
122135
fn request<R>(&self, req: impl serde::Serialize) -> Result<R, Error>
123136
where
124137
R: for<'a> serde::de::Deserialize<'a>,
@@ -533,9 +546,7 @@ impl Builder {
533546

534547
/// Sets the URL of the server to the transport.
535548
pub fn url(mut self, url: &str) -> Result<Self, Error> {
536-
let url = check_url(url)?;
537-
self.tp.addr = url.0;
538-
self.tp.path = url.1;
549+
self.tp.set_url(url)?;
539550
Ok(self)
540551
}
541552

0 commit comments

Comments
 (0)