InputByteStream.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * An abstract means of writing data.
  11. * Classes implementing this interface may use a subsystem which requires less
  12. * memory than working with large strings of data.
  13. * @package Swift
  14. * @subpackage ByteStream
  15. * @author Chris Corbyn
  16. */
  17. interface Swift_InputByteStream
  18. {
  19. /**
  20. * Writes $bytes to the end of the stream.
  21. *
  22. * Writing may not happen immediately if the stream chooses to buffer. If
  23. * you want to write these bytes with immediate effect, call {@link commit()}
  24. * after calling write().
  25. *
  26. * This method returns the sequence ID of the write (i.e. 1 for first, 2 for
  27. * second, etc etc).
  28. *
  29. * @param string $bytes
  30. * @return int
  31. * @throws Swift_IoException
  32. */
  33. public function write($bytes);
  34. /**
  35. * For any bytes that are currently buffered inside the stream, force them
  36. * off the buffer.
  37. *
  38. * @throws Swift_IoException
  39. */
  40. public function commit();
  41. /**
  42. * Attach $is to this stream.
  43. * The stream acts as an observer, receiving all data that is written.
  44. * All {@link write()} and {@link flushBuffers()} operations will be mirrored.
  45. *
  46. * @param Swift_InputByteStream $is
  47. */
  48. public function bind(Swift_InputByteStream $is);
  49. /**
  50. * Remove an already bound stream.
  51. * If $is is not bound, no errors will be raised.
  52. * If the stream currently has any buffered data it will be written to $is
  53. * before unbinding occurs.
  54. *
  55. * @param Swift_InputByteStream $is
  56. */
  57. public function unbind(Swift_InputByteStream $is);
  58. /**
  59. * Flush the contents of the stream (empty it) and set the internal pointer
  60. * to the beginning.
  61. * @throws Swift_IoException
  62. */
  63. public function flushBuffers();
  64. }