Skip to content

Commit

Permalink
get wasm example working
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Jul 3, 2023
1 parent c410b05 commit 103f6de
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions capnp/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ mod std_impls {
mod no_std_impls {
use crate::io::{BufRead, Read, Write};
use crate::{Error, ErrorKind, Result};
#[cfg(feature = "alloc")]
use alloc::string::ToString;

impl<'a> Write for &'a mut [u8] {
fn write_all(&mut self, buf: &[u8]) -> Result<()> {
Expand Down
4 changes: 4 additions & 0 deletions capnp/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//! Convenience wrappers of the datatypes defined in schema.capnp.

#![cfg(feature = "alloc")]

#[cfg(feature = "alloc")]
use alloc::string::ToString;

use crate::dynamic_value;
use crate::introspect::{self, RawBrandedStructSchema, RawEnumSchema};
use crate::private::layout;
Expand Down
2 changes: 1 addition & 1 deletion capnpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ path = "../capnp"
# Doing this forces capnpc to define its own mapping from std::io::Read to capnp::io::Read.
# Fortunately, this is pretty easy, and is just an internal implementation detail.
default-features=false
features=[]
features=["alloc"]
3 changes: 1 addition & 2 deletions example/wasm-hello-world/wasm-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use alloc::alloc::{GlobalAlloc, Layout};
use core::panic::PanicInfo;

// Allocator that fails on every allocation. This is to show that we can read capnproto
// messages without doing any allocations. Note, however, that capnp::Error does allocate,
// so for a real application we would want an actual allocator.
// messages without doing any allocations.
struct NullAllocator;

unsafe impl GlobalAlloc for NullAllocator {
Expand Down

0 comments on commit 103f6de

Please sign in to comment.