Looks good, comments/questions :
- what's the use of readEncoding?
- StreamReadType: add MediaStream? (and others if existing)
- would it be possible to pipe from StreamReadType to other StreamReadType?
- would it be possible to pipe from a source to different targets (my
example of encrypt/hash at the same time)?
- what is the link between the API and the Stream
(responseType='stream')? How do you handle this for APIs where
responseType does not really apply (mspack, crypto...)
Regards
Aymeric
Le 26/09/2013 06:17, Takeshi Yoshino a écrit :
As we don't see any strong demand for flow control and sync read
functionality, I've revised the proposal.
Though we can separate state/error signaling from Stream and keep them
done by each API (e.g. XHR) as Aymeric said, EoF signal still needs to
be conveyed through Stream.
----
enum StreamReadType {
"",
"blob",
"arraybuffer",
"text"
};
interface StreamConsumeResult {
readonly attribute boolean eof;
readonly any data;
readonly unsigned long long size;
};
[Constructor(optional DOMString mime)]
interface Stream {
readonly attribute DOMString type; // MIME type
// Rejected on error. No more write op shouldn't be made.
//
// Fulfilled when the write completes. It doesn't guarantee that the
written data has been
// read out successfully.
//
// The contents of ArrayBufferView must not be modified until the
promise is fulfilled.
//
// Fulfill may be delayed when the Stream considers itself to be full.
//
// write(), close() must not be called again until the Promise of
the last write() is fulfilled.
Promise<void> write((DOMString or ArrayBufferView or Blob)? data);
void close();
attribute StreamReadType readType;
attribute DOMString readEncoding;
// read(), skip(), pipe() must not be called again until the Promise
of the last read(), skip(), pipe() is fulfilled.
// Rejected on error. No more read op shouldn't be made.
//
// If size is specified,
// - if EoF: fulfilled with data up to EoF
// - otherwise: fulfilled with data of size bytes
//
// If size is omitted, (all or part of) data available for read now
will be returned.
//
// If readType is set to text, size of the result may be smaller
than the value specified for the size argument.
Promise<StreamConsumeResult> read(optional [Clamp] long long size);
// Rejected on error. Fulfilled on completion.
//
// .data of result is not used. .size of result is the skipped amount.
Promise<StreamConsumeResult> skip([Clamp] long long size); // .data
is skipped size
// Rejected on error. Fulfilled on completion.
//
// If size is omitted, transfer until EoF is encountered.
//
// .data of result is not used. .size of result is the size of data
transferred.
Promise<StreamConsumeResult> pipe(Stream destination, optional
[Clamp] long long size);
};
--
Peersm : http://www.peersm.com
node-Tor : https://www.github.com/Ayms/node-Tor
GitHub : https://www.github.com/Ayms