Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/base/src/sys/unix/iobuf.rs
5394 views
1
// Copyright 2020 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
use std::ffi::c_void;
6
7
use libc::iovec;
8
9
use crate::iobuf::PlatformIoBuf;
10
11
/// Cross platform binary compatible iovec. See [`crate::IoBufMut`] for documentation.
12
pub type IoBuf = iovec;
13
14
impl PlatformIoBuf for IoBuf {
15
#[inline]
16
fn new(ptr: *mut u8, len: usize) -> Self {
17
iovec {
18
iov_base: ptr as *mut c_void,
19
iov_len: len,
20
}
21
}
22
23
#[inline]
24
fn len(&self) -> usize {
25
self.iov_len
26
}
27
28
#[inline]
29
fn ptr(&self) -> *mut u8 {
30
self.iov_base as *mut u8
31
}
32
33
#[inline]
34
fn set_len(&mut self, len: usize) {
35
self.iov_len = len;
36
}
37
38
#[inline]
39
fn set_ptr(&mut self, ptr: *mut u8) {
40
self.iov_base = ptr as *mut c_void;
41
}
42
}
43
44