blob: e8fd4ec816a777abd3cbede7ebb4bd85823dc454 [file] [log] [blame]
// 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.
// 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.