Skip to content

Commit

Permalink
Update README for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
tikue committed Jun 29, 2024
1 parent 160b561 commit 1ebe906
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 55 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ your `Cargo.toml`:
```toml
anyhow = "1.0"
futures = "0.3"
tarpc = { version = "0.31", features = ["tokio1"] }
tarpc = { version = "0.34", features = ["tokio1"] }
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }
```

Expand All @@ -93,7 +93,6 @@ For a more real-world example, see [example-service](example-service).
First, let's set up the dependencies and service definition.

```rust
use futures::future::{self, Ready};
use tarpc::{
client, context,
server::{self, Channel},
Expand Down
10 changes: 0 additions & 10 deletions tarpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ mod tests {

trait PollTest {
type T;
fn unwrap(self) -> Poll<Self::T>;
fn ready(self) -> Self::T;
}

Expand All @@ -1151,15 +1150,6 @@ mod tests {
{
type T = Option<T>;

fn unwrap(self) -> Poll<Option<T>> {
match self {
Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(t)),
Poll::Ready(None) => Poll::Ready(None),
Poll::Ready(Some(Err(e))) => panic!("{}", e.to_string()),
Poll::Pending => Poll::Pending,
}
}

fn ready(self) -> Option<T> {
match self {
Poll::Ready(Some(Ok(t))) => Some(t),
Expand Down
44 changes: 4 additions & 40 deletions tarpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//! Add to your `Cargo.toml` dependencies:
//!
//! ```toml
//! tarpc = "0.29"
//! tarpc = "0.34"
//! ```
//!
//! The `tarpc::service` attribute expands to a collection of items that form an rpc service.
Expand All @@ -69,7 +69,7 @@
//! ```toml
//! anyhow = "1.0"
//! futures = "0.3"
//! tarpc = { version = "0.29", features = ["tokio1"] }
//! tarpc = { version = "0.34", features = ["tokio1"] }
//! tokio = { version = "1.0", features = ["macros"] }
//! ```
//!
Expand All @@ -83,7 +83,6 @@
//! # extern crate futures;
//!
//! use futures::{
//! future::{self, Ready},
//! prelude::*,
//! };
//! use tarpc::{
Expand All @@ -106,7 +105,6 @@
//! ```rust
//! # extern crate futures;
//! # use futures::{
//! # future::{self, Ready},
//! # prelude::*,
//! # };
//! # use tarpc::{
Expand Down Expand Up @@ -141,7 +139,6 @@
//! ```rust
//! # extern crate futures;
//! # use futures::{
//! # future::{self, Ready},
//! # prelude::*,
//! # };
//! # use tarpc::{
Expand Down Expand Up @@ -253,9 +250,7 @@ pub(crate) mod util;

pub use crate::transport::sealed::Transport;

use anyhow::Context as _;
use futures::task::*;
use std::{any::Any, error::Error, fmt::Display, io, sync::Arc, time::Instant};
use std::{any::Any, error::Error, io, sync::Arc, time::Instant};

/// A message from a client to a server.
#[derive(Debug)]
Expand Down Expand Up @@ -504,37 +499,6 @@ impl<T> Request<T> {
}
}

pub(crate) trait PollContext<T> {
fn context<C>(self, context: C) -> Poll<Option<anyhow::Result<T>>>
where
C: Display + Send + Sync + 'static;

fn with_context<C, F>(self, f: F) -> Poll<Option<anyhow::Result<T>>>
where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C;
}

impl<T, E> PollContext<T> for Poll<Option<Result<T, E>>>
where
E: Error + Send + Sync + 'static,
{
fn context<C>(self, context: C) -> Poll<Option<anyhow::Result<T>>>
where
C: Display + Send + Sync + 'static,
{
self.map(|o| o.map(|r| r.context(context)))
}

fn with_context<C, F>(self, f: F) -> Poll<Option<anyhow::Result<T>>>
where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C,
{
self.map(|o| o.map(|r| r.with_context(f)))
}
}

#[test]
fn test_channel_any_casts() {
use assert_matches::assert_matches;
Expand Down Expand Up @@ -566,7 +530,7 @@ fn test_channel_error_upcast() {

#[derive(Debug)]
struct E;
impl Display for E {
impl fmt::Display for E {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "E")
}
Expand Down
3 changes: 0 additions & 3 deletions tarpc/tests/service_functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ async fn dropped_channel_aborts_in_flight_requests() -> anyhow::Result<()> {
#[derive(Clone)]
struct LoopServer;

#[derive(Debug)]
struct AllHandlersComplete;

impl Loop for LoopServer {
async fn r#loop(self, _: context::Context) {
loop {
Expand Down

0 comments on commit 1ebe906

Please sign in to comment.