1
0
Fork 0
forked from wry/wry

autocommit 2022-01-02 20:11:25 CET

This commit is contained in:
Julian Orth 2022-01-02 20:11:25 +01:00
parent c21f231ce7
commit fc887b339e
29 changed files with 672 additions and 197 deletions

View file

@ -3,7 +3,7 @@ mod types;
use crate::client::{Client, DynEventFormatter};
use crate::globals::{Global, GlobalName};
use crate::object::{Interface, Object, ObjectId};
use crate::utils::buffd::WlParser;
use crate::utils::buffd::MsgParser;
use std::rc::Rc;
pub use types::*;
@ -39,7 +39,7 @@ impl WlRegistry {
})
}
async fn bind(&self, parser: WlParser<'_, '_>) -> Result<(), BindError> {
async fn bind(&self, parser: MsgParser<'_, '_>) -> Result<(), BindError> {
let bind: Bind = self.client.parse(self, parser)?;
let global = self.client.state.globals.get(bind.name)?;
if global.interface().name() != bind.interface {
@ -64,7 +64,7 @@ impl WlRegistry {
async fn handle_request_(
&self,
request: u32,
parser: WlParser<'_, '_>,
parser: MsgParser<'_, '_>,
) -> Result<(), WlRegistryError> {
match request {
BIND => self.bind(parser).await?,

View file

@ -2,7 +2,7 @@ use crate::client::{EventFormatter, RequestParser};
use crate::globals::{Global, GlobalError, GlobalName};
use crate::ifs::wl_registry::{WlRegistry, GLOBAL, GLOBAL_REMOVE};
use crate::object::{Interface, Object, ObjectId};
use crate::utils::buffd::{WlFormatter, WlParser, WlParserError};
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
use std::fmt::{Debug, Formatter};
use std::rc::Rc;
use thiserror::Error;
@ -18,7 +18,7 @@ efrom!(WlRegistryError, BindError, BindError);
#[derive(Debug, Error)]
pub enum BindError {
#[error("Parsing failed")]
ParseError(#[source] Box<WlParserError>),
ParseError(#[source] Box<MsgParserError>),
#[error(transparent)]
GlobalError(Box<GlobalError>),
#[error("Tried to bind to global {} of type {} using interface {}", .0.name, .0.interface.name(), .0.actual)]
@ -42,7 +42,7 @@ pub struct VersionError {
pub actual: u32,
}
efrom!(BindError, ParseError, WlParserError);
efrom!(BindError, ParseError, MsgParserError);
efrom!(BindError, GlobalError, GlobalError);
pub(super) struct GlobalE {
@ -50,7 +50,7 @@ pub(super) struct GlobalE {
pub global: Rc<dyn Global>,
}
impl EventFormatter for GlobalE {
fn format(self: Box<Self>, fmt: &mut WlFormatter<'_>) {
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
fmt.header(self.obj.id, GLOBAL)
.uint(self.global.name().raw())
.string(self.global.interface().name())
@ -77,7 +77,7 @@ pub(super) struct GlobalRemove {
pub name: GlobalName,
}
impl EventFormatter for GlobalRemove {
fn format(self: Box<Self>, fmt: &mut WlFormatter<'_>) {
fn format(self: Box<Self>, fmt: &mut MsgFormatter<'_>) {
fmt.header(self.obj.id, GLOBAL_REMOVE).uint(self.name.raw());
}
fn obj(&self) -> &dyn Object {
@ -97,7 +97,7 @@ pub(super) struct Bind<'a> {
pub version: u32,
}
impl<'a> RequestParser<'a> for Bind<'a> {
fn parse(parser: &mut WlParser<'_, 'a>) -> Result<Self, WlParserError> {
fn parse(parser: &mut MsgParser<'_, 'a>) -> Result<Self, MsgParserError> {
Ok(Self {
name: parser.global()?,
interface: parser.string()?,