mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
xous: add send() to String
This call can be used to send a string to a Server. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
7ab2338ff3
commit
08fb5e0a0b
1 changed files with 14 additions and 1 deletions
|
|
@ -46,7 +46,7 @@ impl<'a> String<'a> {
|
|||
|
||||
/// Perform an immutable lend of this String to the specified server.
|
||||
/// This function will block until the server returns.
|
||||
pub fn lend(&self, connection: CID, id: usize) -> core::result::Result<Result, Error> {
|
||||
pub fn lend(&self, connection: CID, id: crate::MessageId) -> core::result::Result<Result, Error> {
|
||||
let memory_range =
|
||||
MemoryRange::new(self.raw_slice.as_ptr() as _, self.raw_slice.len()).unwrap();
|
||||
let msg = MemoryMessage {
|
||||
|
|
@ -58,6 +58,19 @@ impl<'a> String<'a> {
|
|||
send_message(connection, Message::Borrow(msg))
|
||||
}
|
||||
|
||||
/// Move this string from the client into the server.
|
||||
pub fn send(self, connection: CID, id: crate::MessageId) -> core::result::Result<Result, Error> {
|
||||
let memory_range =
|
||||
MemoryRange::new(self.raw_slice.as_ptr() as _, self.raw_slice.len()).unwrap();
|
||||
let msg = MemoryMessage {
|
||||
id,
|
||||
buf: memory_range,
|
||||
offset: None,
|
||||
valid: MemorySize::new(self.len).map(Some).unwrap_or(None),
|
||||
};
|
||||
send_message(connection, Message::Move(msg))
|
||||
}
|
||||
|
||||
/// Clear the contents of this String and set the length to 0
|
||||
pub fn clear(&mut self) {
|
||||
self.len = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue