Skip to content

Commit fa92e2f

Browse files
committed
update capnp_futures::serialize::read_message() to not return an option
1 parent 7b42c69 commit fa92e2f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

capnp-futures/src/serialize.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ use capnp::serialize::{OwnedSegments, SegmentLengthsBuilder};
2828

2929
use futures::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
3030

31-
#[deprecated(since = "0.13.2", note = "This function was renamed to try_read_message()")]
32-
pub async fn read_message<R>(reader: R, options: message::ReaderOptions) -> Result<Option<message::Reader<OwnedSegments>>>
33-
where R: AsyncRead + Unpin
31+
32+
/// Asynchronously reads a message from `reader`.
33+
pub async fn read_message<R>(reader: R, options: message::ReaderOptions)
34+
-> Result<message::Reader<OwnedSegments>>
35+
where R: AsyncRead + Unpin
3436
{
35-
try_read_message(reader, options).await
37+
match try_read_message(reader, options).await? {
38+
Some(s) => Ok(s),
39+
None => Err(Error::failed("Premature end of file".to_string()))
40+
}
3641
}
3742

38-
3943
/// Asynchronously reads a message from `reader`. Returns `None` if `reader`
4044
/// has zero bytes left (i.e. is at end-of-file). To read a stream
4145
/// containing an unknown number of messages, you could call this function

0 commit comments

Comments
 (0)