Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/base/src/sys/windows/iobuf.rs
5394 views
1
// Copyright 2022 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 winapi::shared::ws2def::WSABUF;
6
7
use crate::iobuf::PlatformIoBuf;
8
9
/// Cross platform binary compatible iovec. See [`crate::IoBufMut`] for documentation.
10
pub type IoBuf = WSABUF;
11
12
impl PlatformIoBuf for IoBuf {
13
#[inline]
14
fn new(ptr: *mut u8, len: usize) -> Self {
15
WSABUF {
16
buf: ptr as *mut i8,
17
len: len.try_into().unwrap(),
18
}
19
}
20
21
#[inline]
22
fn len(&self) -> usize {
23
self.len as usize
24
}
25
26
#[inline]
27
fn ptr(&self) -> *mut u8 {
28
self.buf as *mut u8
29
}
30
31
#[inline]
32
fn set_len(&mut self, len: usize) {
33
self.len = len.try_into().unwrap();
34
}
35
36
#[inline]
37
fn set_ptr(&mut self, ptr: *mut u8) {
38
self.buf = ptr as *mut i8;
39
}
40
}
41
42