blob: 9fa3f441aae07c5eb50a8e44b2786c92ef5490f0 [file] [log] [blame] [edit]
/*
* CAmkES backing for Rust Read and Write traits.
*
* Copyright 2021, Google LLC
* Apache License 2.0
*
* These CAmkES interfaces express the standard Rust read() and write()
* signatures, assuming two separate, externally defined, and implicitly
* associated dataports for each of read and write.
*
* It is intended that Rust code be able to use extern "C" declarations
* referencing the camkes.h that this will generate as the core of
* implementations of the Read and Write traits.
*/
procedure rust_read_inf {
// Reads up to limit bytes into the read dataport.
//
// Returns the number of bytes read or a negative value if there is any
// error.
int read(in size_t limit);
};
procedure rust_write_inf {
// Writes up to a given number of bytes from the write dataport.
//
// Returns the number of bytes actually written or a negative value if there
// is any error. For non-negative return values < available, the caller is
// reponsible for retrying with the remaining bytes at the beginning of the
// write dataport.
int write(in size_t available);
// Blocks until all bytes so far written have been pushed to the real sink.
//
// The semantics are the same as Rust's Write::flush. Returns 0 on success
// and a negative value if there is any error.
int flush();
}