Skip to content

Commit

Permalink
Merge pull request extism#11 from extism/msgpack
Browse files Browse the repository at this point in the history
feat: add msgpack support
  • Loading branch information
zshipko authored Dec 8, 2022
2 parents 6623e0c + 1885767 commit c766c11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ anyhow = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
extism-pdk-derive = {path = "./derive", version = "0.1.0"}
extism-manifest = {version = "0.0.1", optional = true}
extism-manifest = {version = "0.1.0", optional = true}
rmp-serde = {version = "1", optional = true}
base64 = "0.20.0-alpha.1"
[features]
default = ["http"]
default = ["http", "msgpack"]
http = ["extism-manifest"]
msgpack = ["rmp-serde"]

[workspace]
members = [
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod to_memory;
pub mod var;

#[cfg(feature = "http")]
/// Types and functions for making HTTP requests
pub mod http;

pub use anyhow::Error;
Expand All @@ -18,9 +19,11 @@ pub use memory::Memory;
pub use to_memory::ToMemory;

#[cfg(feature = "http")]
/// HTTP request type
pub use extism_manifest::HttpRequest;

#[cfg(feature = "http")]
/// HTTP response type
pub use http::HttpResponse;

/// The return type of a plugin function
Expand All @@ -39,10 +42,18 @@ pub enum LogLevel {
pub use serde_json as json;

use crate as extism_pdk;

/// JSON encoding
#[encoding(serde_json::to_vec, serde_json::from_slice)]
pub struct Json;

/// MsgPack encoding
#[cfg_attr(
feature = "msgpack",
encoding(rmp_serde::to_vec, rmp_serde::from_slice)
)]
pub struct MsgPack;

/// Base64 conversion
pub struct Base64(pub String);

Expand Down

0 comments on commit c766c11

Please sign in to comment.