[wlan][mlme] Introduce OutBuf
OutBuf is used to return a buffer to Fuchsia's C++ MLME.
Unlike InBuf, it will not automatically return and free the buffer
once it goes out of scope.
The key idea is to ask C++ MLME for an InBuf via Rust's
BufferProvider, write to the buffer and once all operations
executed successfully turn the InBuf into an OutBuf and return
it to C++.
This system ensures that all buffers taken from the C++ MLME
are guaranteed to be returned. Example code:
fn foo(mut buf: InBuf, bar: usize) -> Result<OutBuf, Error> {
ensure!(bar > 10, "unexpected bar");
let written_bytes = write_frame(&mut buf)?;
Ok(OutBuf::from(buf, written_bytes))
}
Test=Included
Change-Id: I02b05b046f8718bade31c421a23b5ce324cf9bc9
7 files changed