Lines Matching defs:stream
172 /// Constructs a <see cref="ByteString"/> from data in the given stream, synchronously.
174 /// <remarks>If successful, <paramref name="stream"/> will be read completely, from the position
176 /// <param name="stream">The stream to copy into a ByteString.</param>
177 /// <returns>A ByteString with content read from the given stream.</returns>
178 public static ByteString FromStream(Stream stream)
180 ProtoPreconditions.CheckNotNull(stream, nameof(stream));
181 int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0;
183 stream.CopyTo(memoryStream);
195 /// Constructs a <see cref="ByteString"/> from data in the given stream, asynchronously.
197 /// <remarks>If successful, <paramref name="stream"/> will be read completely, from the position
199 /// <param name="stream">The stream to copy into a ByteString.</param>
200 /// <param name="cancellationToken">The cancellation token to use when reading from the stream, if any.</param>
201 /// <returns>A ByteString with content read from the given stream.</returns>
202 public async static Task<ByteString> FromStreamAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
204 ProtoPreconditions.CheckNotNull(stream, nameof(stream));
205 int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0;
209 await stream.CopyToAsync(memoryStream, 81920, cancellationToken);
426 /// Writes the entire byte array to the provided stream