WriteOptions.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #region Copyright notice and license
  2. // Copyright 2015-2016 gRPC authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. namespace Grpc.Core
  18. {
  19. /// <summary>
  20. /// Flags for write operations.
  21. /// </summary>
  22. [Flags]
  23. public enum WriteFlags
  24. {
  25. /// <summary>
  26. /// Hint that the write may be buffered and need not go out on the wire immediately.
  27. /// gRPC is free to buffer the message until the next non-buffered
  28. /// write, or until write stream completion, but it need not buffer completely or at all.
  29. /// </summary>
  30. BufferHint = 0x1,
  31. /// <summary>
  32. /// Force compression to be disabled for a particular write.
  33. /// </summary>
  34. NoCompress = 0x2
  35. }
  36. /// <summary>
  37. /// Options for write operations.
  38. /// </summary>
  39. public class WriteOptions
  40. {
  41. /// <summary>
  42. /// Default write options.
  43. /// </summary>
  44. public static readonly WriteOptions Default = new WriteOptions();
  45. private readonly WriteFlags flags;
  46. /// <summary>
  47. /// Initializes a new instance of <c>WriteOptions</c> class.
  48. /// </summary>
  49. /// <param name="flags">The write flags.</param>
  50. public WriteOptions(WriteFlags flags = default(WriteFlags))
  51. {
  52. this.flags = flags;
  53. }
  54. /// <summary>
  55. /// Gets the write flags.
  56. /// </summary>
  57. public WriteFlags Flags
  58. {
  59. get
  60. {
  61. return this.flags;
  62. }
  63. }
  64. }
  65. }