xref: /qemu/rust/qemu-api/src/chardev.rs (revision 48627510a7fed7a045358743e6b869a98931f85e)
1 // Copyright 2024 Red Hat, Inc.
2 // Author(s): Paolo Bonzini <pbonzini@redhat.com>
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 
5 //! Bindings for character devices
6 
7 use std::ffi::CStr;
8 
9 use crate::{bindings, cell::Opaque, prelude::*};
10 
11 /// A safe wrapper around [`bindings::Chardev`].
12 #[repr(transparent)]
13 #[derive(qemu_api_macros::Wrapper)]
14 pub struct Chardev(Opaque<bindings::Chardev>);
15 
16 pub type ChardevClass = bindings::ChardevClass;
17 
18 unsafe impl ObjectType for Chardev {
19     type Class = ChardevClass;
20     const TYPE_NAME: &'static CStr =
21         unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_CHARDEV) };
22 }
23 qom_isa!(Chardev: Object);
24