Skip to content

Commit

Permalink
Merge pull request #92 from mahkoh/jorth/bincode1
Browse files Browse the repository at this point in the history
config: downgrade bincode to 1.3.3
  • Loading branch information
mahkoh authored Feb 16, 2024
2 parents 6921531 + 615acd4 commit 63ed3fa
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 104 deletions.
22 changes: 4 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ once_cell = "1.19.0"
rand = "0.8.5"
smallvec = { version = "1.11.1", features = ["const_generics", "const_new", "union"] }
byteorder = "1.5.0"
bincode = "2.0.0-rc.3"
bincode = "1.3.3"
jay-config = { path = "jay-config" }
default-config = { path = "default-config" }
algorithms = { path = "algorithms" }
Expand All @@ -46,6 +46,7 @@ indexmap = "2.2.0"
ash = "0.37.3"
gpu-alloc = "0.6.0"
gpu-alloc-ash = "0.6.0"
serde = { version = "1.0.196", features = ["derive"] }

[build-dependencies]
repc = "0.1.1"
Expand Down
3 changes: 2 additions & 1 deletion jay-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ license = "GPL-3.0-only"
description = "Configuration crate for the Jay compositor"

[dependencies]
bincode = "2.0.0-rc.1"
bincode = "1.3.3"
serde = { version = "1.0.196", features = ["derive"] }
log = "0.4.14"
8 changes: 4 additions & 4 deletions jay-config/src/_private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod client;
pub mod ipc;
mod logging;

use std::marker::PhantomData;
use {bincode::Options, std::marker::PhantomData};

pub const VERSION: u32 = 1;

Expand All @@ -26,9 +26,9 @@ pub struct ConfigEntryGen<T> {

impl<T: Config> ConfigEntryGen<T> {}

pub fn bincode_ops() -> impl bincode::config::Config {
bincode::config::standard()
.with_fixed_int_encoding()
pub fn bincode_ops() -> impl Options {
bincode::DefaultOptions::new()
.with_fixint_encoding()
.with_little_endian()
.with_no_limit()
}
Expand Down
9 changes: 5 additions & 4 deletions jay-config/src/_private/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use {
},
Axis, Direction, ModifiedKeySym, PciId, Workspace,
},
bincode::Options,
std::{
cell::{Cell, RefCell},
collections::{hash_map::Entry, HashMap},
Expand Down Expand Up @@ -171,7 +172,7 @@ impl Client {
fn send(&self, msg: &ClientMessage) {
let mut buf = self.bufs.borrow_mut().pop().unwrap_or_default();
buf.clear();
bincode::encode_into_std_write(msg, &mut buf, bincode_ops()).unwrap();
bincode_ops().serialize_into(&mut buf, msg).unwrap();
unsafe {
(self.srv_handler)(self.srv_data, buf.as_ptr(), buf.len());
}
Expand Down Expand Up @@ -700,8 +701,8 @@ impl Client {
}

fn handle_msg(&self, msg: &[u8]) {
let res = bincode::borrow_decode_from_slice::<ServerMessage, _>(msg, bincode_ops());
let (msg, _) = match res {
let res = bincode_ops().deserialize::<ServerMessage>(msg);
let msg = match res {
Ok(msg) => msg,
Err(e) => {
let msg = format!("could not deserialize message: {}", e);
Expand Down Expand Up @@ -787,7 +788,7 @@ impl Client {
}

fn handle_init_msg(&self, msg: &[u8]) {
let (init, _) = match bincode::decode_from_slice::<InitMessage, _>(msg, bincode_ops()) {
let init = match bincode_ops().deserialize::<InitMessage>(msg) {
Ok(m) => m,
Err(e) => {
let msg = format!("could not deserialize message: {}", e);
Expand Down
12 changes: 6 additions & 6 deletions jay-config/src/_private/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use {
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi},
Axis, Direction, PciId, Workspace,
},
bincode::{BorrowDecode, Decode, Encode},
serde::{Deserialize, Serialize},
std::time::Duration,
};

#[derive(Encode, BorrowDecode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub enum ServerMessage {
Configure {
reload: bool,
Expand Down Expand Up @@ -58,7 +58,7 @@ pub enum ServerMessage {
DevicesEnumerated,
}

#[derive(Encode, BorrowDecode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub enum ClientMessage<'a> {
Reload,
Quit,
Expand Down Expand Up @@ -340,7 +340,7 @@ pub enum ClientMessage<'a> {
},
}

#[derive(Encode, Decode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub enum Response {
None,
GetSeats {
Expand Down Expand Up @@ -442,10 +442,10 @@ pub enum Response {
},
}

#[derive(Encode, Decode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub enum InitMessage {
V1(V1InitMessage),
}

#[derive(Encode, Decode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub struct V1InitMessage {}
6 changes: 3 additions & 3 deletions jay-config/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use {
keyboard::Keymap,
Axis, Direction, ModifiedKeySym, Workspace,
},
bincode::{Decode, Encode},
serde::{Deserialize, Serialize},
};

/// An input device.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct InputDevice(pub u64);

impl InputDevice {
Expand Down Expand Up @@ -114,7 +114,7 @@ impl InputDevice {
}

/// A seat.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Seat(pub u64);

impl Seat {
Expand Down
4 changes: 2 additions & 2 deletions jay-config/src/input/acceleration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//!
//! See the libinput documentation for details.
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// The acceleration profile of a device.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct AccelProfile(pub u32);

/// A flat acceleration profile.
Expand Down
4 changes: 2 additions & 2 deletions jay-config/src/input/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//!
//! See the libinput documentation for the meanings of these constants.
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// A capability of an input device.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Capability(pub u32);

pub const CAP_KEYBOARD: Capability = Capability(0);
Expand Down
6 changes: 3 additions & 3 deletions jay-config/src/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
use {
crate::keyboard::{mods::Modifiers, syms::KeySym},
bincode::{Decode, Encode},
serde::{Deserialize, Serialize},
std::ops::{BitOr, BitOrAssign},
};

pub mod mods;
pub mod syms;

/// A keysym with zero or more modifiers
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct ModifiedKeySym {
pub mods: Modifiers,
pub sym: KeySym,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl BitOrAssign<Modifiers> for ModifiedKeySym {
}

/// A keymap.
#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct Keymap(pub u64);

impl Keymap {
Expand Down
4 changes: 2 additions & 2 deletions jay-config/src/keyboard/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
use {
crate::{keyboard::syms::KeySym, ModifiedKeySym},
bincode::{Decode, Encode},
serde::{Deserialize, Serialize},
std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign},
};

/// Zero or more keyboard modifiers
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Default, Hash, Debug)]
#[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Default, Hash, Debug)]
pub struct Modifiers(pub u32);

/// The Shift modifier
Expand Down
4 changes: 2 additions & 2 deletions jay-config/src/keyboard/syms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#![allow(non_upper_case_globals)]

use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// A keysym.
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct KeySym(pub u32);

pub const SYM_BackSpace: KeySym = KeySym(0xff08);
Expand Down
10 changes: 5 additions & 5 deletions jay-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

use {
crate::keyboard::ModifiedKeySym,
bincode::{Decode, Encode},
serde::{Deserialize, Serialize},
std::fmt::{Debug, Display, Formatter},
};

Expand All @@ -61,7 +61,7 @@ pub mod timer;
pub mod video;

/// A planar direction.
#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq)]
pub enum Direction {
Left,
Down,
Expand All @@ -70,7 +70,7 @@ pub enum Direction {
}

/// A planar axis.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum Axis {
Horizontal,
Vertical,
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn toggle_default_workspace_capture() {
}

/// A workspace.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Workspace(pub u64);

impl Workspace {
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn get_workspace(name: &str) -> Workspace {
/// PCI IDs can be used to identify a hardware component. See the Debian [documentation][pci].
///
/// [pci]: https://wiki.debian.org/HowToIdentifyADevice/PCI
#[derive(Encode, Decode, Debug, Copy, Clone, Hash, Eq, PartialEq, Default)]
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Hash, Eq, PartialEq, Default)]
pub struct PciId {
pub vendor: u32,
pub model: u32,
Expand Down
4 changes: 2 additions & 2 deletions jay-config/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
//! Note that you can use the `log` crate for logging. All invocations of `log::info` etc.
//! automatically log into the compositors log.
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// The log level of the compositor or a log message.
#[derive(Encode, Decode, Copy, Clone, Debug)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
pub enum LogLevel {
Error,
Warn,
Expand Down
12 changes: 6 additions & 6 deletions jay-config/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Tools for configuring the look of the compositor.
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// A color.
///
Expand All @@ -15,7 +15,7 @@ use bincode::{Decode, Encode};
///
/// When using hexadecimal notation, `#RRGGBBAA`, the RGB values are usually straight.
// values are stored premultiplied
#[derive(Encode, Decode, Debug)]
#[derive(Serialize, Deserialize, Debug)]
pub struct Color {
r: f32,
g: f32,
Expand Down Expand Up @@ -160,11 +160,11 @@ pub fn reset_font() {
pub mod colors {
use {
crate::theme::Color,
bincode::{Decode, Encode},
serde::{Deserialize, Serialize},
};

/// An element of the GUI whose color can be changed.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Colorable(#[doc(hidden)] pub u32);

impl Colorable {
Expand Down Expand Up @@ -262,10 +262,10 @@ pub mod colors {

/// Elements of the compositor whose size can be changed.
pub mod sized {
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};

/// An element of the GUI whose size can be changed.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Resizable(#[doc(hidden)] pub u32);

impl Resizable {
Expand Down
Loading

0 comments on commit 63ed3fa

Please sign in to comment.