use {super::super::all_types::*, crate::builder::prelude::*};
static INTERFACE: wl_interface = wl_interface {
name: c"wl_string".as_ptr(),
version: 1,
method_count: 0,
methods: ptr::null(),
event_count: 1,
events: {
static MESSAGES: [wl_message; 1] = [wl_message {
name: c"string".as_ptr(),
signature: c"s".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 1] = [None];
TYPES.as_ptr().cast()
},
}];
MESSAGES.as_ptr()
},
};
#[derive(Clone, Eq, PartialEq)]
#[repr(transparent)]
pub struct WlString {
proxy: UntypedOwnedProxy,
}
#[derive(Eq, PartialEq)]
#[repr(transparent)]
pub struct WlStringRef {
proxy: UntypedBorrowedProxy,
}
unsafe impl UntypedOwnedProxyWrapper for WlString {}
unsafe impl OwnedProxy for WlString {
const INTERFACE: &'static str = "wl_string";
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
private::EventHandler(private::NoOpEventHandler);
const MAX_VERSION: u32 = 1;
type Borrowed = WlStringRef;
type Api = private::ProxyApi;
type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
}
unsafe impl UntypedBorrowedProxyWrapper for WlStringRef {}
unsafe impl BorrowedProxy for WlStringRef {
type Owned = WlString;
}
impl Deref for WlString {
type Target = WlStringRef;
fn deref(&self) -> &Self::Target {
proxy::low_level::deref(self)
}
}
mod private {
pub struct ProxyApi;
#[allow(dead_code)]
pub struct EventHandler<H>(pub(super) H);
#[allow(dead_code)]
pub struct NoOpEventHandler;
}
impl Debug for WlString {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wl_string#{}", self.proxy.id())
}
}
impl Debug for WlStringRef {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wl_string#{}", self.proxy.id())
}
}
impl PartialEq<WlStringRef> for WlString {
fn eq(&self, other: &WlStringRef) -> bool {
self.proxy == other.proxy
}
}
impl PartialEq<WlString> for WlStringRef {
fn eq(&self, other: &WlString) -> bool {
self.proxy == other.proxy
}
}
impl WlString {
#[allow(dead_code)]
pub const EVT__STRING__SINCE: u32 = 1;
}
#[allow(dead_code)]
pub trait WlStringEventHandler {
#[inline]
fn string(&self, _slf: &WlStringRef, string: &str) {
let _ = string;
}
}
impl WlStringEventHandler for private::NoOpEventHandler {}
unsafe impl<H> EventHandler for private::EventHandler<H>
where
H: WlStringEventHandler,
{
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
#[allow(unused_variables)]
unsafe fn handle_event(
&self,
queue: &Queue,
data: *mut u8,
slf: &UntypedBorrowedProxy,
opcode: u32,
args: *mut wl_argument,
) {
let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlStringRef>(slf) };
match opcode {
0 => {
let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
let arg0 = unsafe { convert_string_arg("wl_string", "string", args[0].s) };
self.0.string(slf, arg0);
}
_ => {
invalid_opcode("wl_string", opcode);
}
}
}
}
impl<H> CreateEventHandler<H> for private::ProxyApi
where
H: WlStringEventHandler,
{
type EventHandler = private::EventHandler<H>;
#[inline]
fn create_event_handler(handler: H) -> Self::EventHandler {
private::EventHandler(handler)
}
}
pub mod event_handlers {
use super::*;
pub struct String<F>(F);
impl<F> WlStringEventHandler for String<F>
where
F: Fn(&WlStringRef, &str),
{
#[inline]
fn string(&self, _slf: &WlStringRef, string: &str) {
self.0(_slf, string)
}
}
impl WlString {
#[allow(dead_code)]
pub fn on_string<F>(f: F) -> String<F>
where
F: Fn(&WlStringRef, &str),
{
String(f)
}
}
}