blob: 3751d549e396e2793d7d46b761587134a3c7b749 [file] [log] [blame]
Jan Tattermuscha5272b62015-04-30 11:56:46 -07001#region Copyright notice and license
Jan Tattermuscha7fff862015-02-13 11:08:08 -08002
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003// Copyright 2015 gRPC authors.
Craig Tiller190d3602015-02-18 09:23:38 -08004//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
Craig Tiller190d3602015-02-18 09:23:38 -08008//
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009// http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller190d3602015-02-18 09:23:38 -080010//
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
Jan Tattermuscha7fff862015-02-13 11:08:08 -080016
17#endregion
18
Jan Tattermuscha7608b02015-02-03 17:54:38 -080019using System;
Jan Tattermuscha7608b02015-02-03 17:54:38 -080020using System.Collections.Generic;
Jan Tattermuscha5272b62015-04-30 11:56:46 -070021using System.Linq;
22using System.Text;
Jan Tattermusch30868622015-02-19 09:22:33 -080023using System.Threading.Tasks;
Jan Tattermuscha7608b02015-02-03 17:54:38 -080024
Jan Tattermuscha5272b62015-04-30 11:56:46 -070025namespace Grpc.Core
Jan Tattermuscha7608b02015-02-03 17:54:38 -080026{
Jan Tattermuscha5272b62015-04-30 11:56:46 -070027 /// <summary>
28 /// A stream of messages to be read.
Jan Tattermusch2eb09ee2016-06-14 17:50:20 -070029 /// Messages can be awaited <c>await reader.MoveNext()</c>, that returns <c>true</c>
30 /// if there is a message available and <c>false</c> if there are no more messages
31 /// (i.e. the stream has been closed).
32 /// <para>
33 /// On the client side, the last invocation of <c>MoveNext()</c> either returns <c>false</c>
34 /// if the call has finished successfully or throws <c>RpcException</c> if call finished
35 /// with an error. Once the call finishes, subsequent invocations of <c>MoveNext()</c> will
36 /// continue yielding the same result (returning <c>false</c> or throwing an exception).
37 /// </para>
38 /// <para>
39 /// On the server side, <c>MoveNext()</c> does not throw exceptions.
40 /// In case of a failure, the request stream will appear to be finished
41 /// (<c>MoveNext</c> will return <c>false</c>) and the <c>CancellationToken</c>
42 /// associated with the call will be cancelled to signal the failure.
43 /// </para>
Jan Tattermuschbb872c02017-10-04 16:59:49 +020044 /// <para>
45 /// <c>MoveNext()</c> operations can be cancelled via a cancellation token. Cancelling
46 /// an individual read operation has the same effect as cancelling the entire call
Jan Tattermuschee352232017-10-05 16:11:34 +020047 /// (which will also result in the read operation returning prematurely), but the per-read cancellation
48 /// tokens passed to MoveNext() only result in cancelling the call if the read operation haven't finished
49 /// yet.
Jan Tattermuschbb872c02017-10-04 16:59:49 +020050 /// </para>
Jan Tattermuscha5272b62015-04-30 11:56:46 -070051 /// </summary>
Jan Tattermusch12855fc2015-08-24 16:43:23 -070052 /// <typeparam name="T">The message type.</typeparam>
Jan Tattermusch4dd25092015-08-09 01:01:33 -070053 public interface IAsyncStreamReader<T> : IAsyncEnumerator<T>
Jan Tattermuscha7608b02015-02-03 17:54:38 -080054 {
Jan Tattermuscha7608b02015-02-03 17:54:38 -080055 }
56}