diff --git a/edgedb-protocol/src/serialization/decode/queryable/scalars.rs b/edgedb-protocol/src/serialization/decode/queryable/scalars.rs index 08367141..56ecfb82 100644 --- a/edgedb-protocol/src/serialization/decode/queryable/scalars.rs +++ b/edgedb-protocol/src/serialization/decode/queryable/scalars.rs @@ -1,3 +1,5 @@ +use bytes::Bytes; + use crate::queryable::DescriptorMismatch; use crate::queryable::{Decoder, DescriptorContext, Queryable}; @@ -56,6 +58,15 @@ impl DecodeScalar for String { } } +impl DecodeScalar for Bytes { + fn uuid() -> Uuid { + codec::STD_BYTES + } + fn typename() -> &'static str { + "std::bytes" + } +} + impl DecodeScalar for Json { fn uuid() -> Uuid { codec::STD_JSON diff --git a/edgedb-protocol/src/value.rs b/edgedb-protocol/src/value.rs index 27532414..2708f152 100644 --- a/edgedb-protocol/src/value.rs +++ b/edgedb-protocol/src/value.rs @@ -1,8 +1,6 @@ /*! Contains the [Value] enum. */ -use bytes::Bytes; - pub use crate::codec::EnumValue; use crate::codec::{NamedTupleShape, ObjectShape, ShapeElement}; use crate::common::Cardinality; @@ -15,7 +13,7 @@ pub enum Value { Nothing, Uuid(Uuid), Str(String), - Bytes(Bytes), + Bytes(bytes::Bytes), Int16(i16), Int32(i32), Int64(i64), diff --git a/edgedb-tokio/tests/func/client.rs b/edgedb-tokio/tests/func/client.rs index 62196a94..d75a3561 100644 --- a/edgedb-tokio/tests/func/client.rs +++ b/edgedb-tokio/tests/func/client.rs @@ -217,3 +217,22 @@ async fn big_num() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test] +async fn bytes() -> anyhow::Result<()> { + let client = Client::new(&SERVER.config); + client.ensure_connected().await?; + + #[derive(Queryable)] + struct MyResult { + data: bytes::Bytes, + } + + let res = client + .query_required_single::("select { data := b'101' } limit 1", &()) + .await + .unwrap(); + + assert_eq!(res.data, b"101"[..]); + Ok(()) +} diff --git a/flake.nix b/flake.nix index f28f5f8c..ad242959 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ buildInputs = [ (fenix_pkgs.fromToolchainFile { file = ./rust-toolchain.toml; - sha256 = "sha256-6eN/GKzjVSjEhGO9FhWObkRFaE1Jf+uqMSdQnb8lcB4="; + sha256 = "sha256-3jVIIf5XPnUU1CRaTyAiO0XHVbJl12MSx3eucTXCjtE="; }) ] ++ common; };