summaryrefslogtreecommitdiffstats
path: root/device/serial/data_stream.mojom
blob: e8fd4ec816a777abd3cbede7ebb4bd85823dc454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module device.serial;

interface DataSource {
  // Initializes this DataSource with the amount of data its client will
  // buffer.
  Init(uint32 buffer_size);

  // Resumes sending data after it has been stopped due to an error.
  Resume();

  // Reports that |bytes_sent| bytes have been successfully passed to the
  // client.
  ReportBytesReceived(uint32 bytes_sent);
};

interface DataSourceClient {
  // Invoked to report |error| from the DataSource. No further bytes will be
  // transmitted from the DataSource until Resume() is called.
  OnError(int32 error);

  // Invoked to transmit data from the DataSource.
  OnData(array<uint8> data);
};

interface DataSink {
  // Requests the cancellation of any data that has been written to the pipe,
  // but has not yet been sent to the sink.
  Cancel(int32 error);

  // Invoked to pass |data| to the sink. The response contains the number of
  // bytes successfully sent and an optional error. If |error| is zero,
  // |bytes_sent| will the size of |data|.
  OnData(array<uint8> data) => (uint32 bytes_sent, int32 error);

  // Called to clear the error and resume data transmission after an error
  // occurs. After an error is reported in response to an OnData until
  // ClearError is called, any further OnData calls will report the same error
  // as the first error response.
  ClearError();
};