text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>use std::{ collections::BTreeMap, str::FromStr, time::{SystemTime, UNIX_EPOCH}, }; use webc::{ AbstractVolume, Metadata, PathSegment, PathSegments, v3::{self, write::FileEntry}, }; use crate::package::Strictness; use super::WasmerPackageVolume; /// An in-memory representation of a ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> AbstractVolume + Send + Sync + 'static> for T { fn into_super(self: Arc<Self>) -> Arc<dyn AbstractVolume + Send + Sync + 'static> { self } } /// An abstraction over concrete volumes implementation to be used in a Wasmer Package. pub trait WasmerPackageVolume: AbstractVolume + Sen...
fim
wasmerio/wasmer
rust
<|fim_suffix|>clippy::result_large_err)] fn parse_v3_mmap(f: File) -> Result<Container, ContainerError> { // Note: OwnedReader::from_file() will automatically try to // use a memory-mapped file when possible. let webc = webc::v3::read::OwnedReader::from_file(f)?; Ok(Container::new(webc)) } /// Convert ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ait { let header = res .headers() .get(HEADER_APP_VERSION_ID) .and_then(|v| v.to_str().ok()) .unwrap_or(""); if header == version.id.inner() { bre...
fim
wasmerio/wasmer
rust
<|fim_suffix|>e.join("keep.txt"), "keep me")?; fs::create_dir_all(base.join("ignored_dir"))?; fs::write(base.join("ignored_dir/file.txt"), "ignored dir file")?; fs::create_dir_all(base.join("keep_dir"))?; fs::write(base.join("keep_dir/keep.txt"), "keep dir file")?; Ok(()) } }...
fim
wasmerio/wasmer
rust
<|fim_suffix|> apps deployed on Wasmer Edge. pub mod deploy; pub mod deploy_remote_build; <|fim_prefix|>//! Provides tooling related<|fim_middle|> to<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_suffix|>er-sdk is a utility library for interacting with the Wasmer ecosystem. pub mod app; pub mod package; <|fim_prefix|>//<|fim_middle|>! wasm<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_suffix|>s. pub mod publish; <|fim_prefix|>//! Provides <|fim_middle|>functionality for Wasmer package<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Provides package publishing functionality. use std::{ path::{Path, PathBuf}, time::Duration, }; use anyhow::{self, Context as _}; use futures_util::StreamExt; use semver::Version; use sha2::{Digest, Sha256}; use thiserror::Error; use toml; use wasmer_backend_api::{WasmerClient, query::Uploa...
fim
wasmerio/wasmer
rust
<|fim_suffix|>}).await?; Ok(()) } <|fim_prefix|>use std::fs; use std::time::Duration; use rand::RngExt; use semver::Version; use tempfile::tempdir; use url::Url; use wasmer_backend_api::WasmerClient; use wasmer_sdk::package::publish::{PublishOptions, PublishWait, publish_package_directory}; /// Integration test...
fim
wasmerio/wasmer
rust
<|fim_suffix|>./src/lib.udl").unwrap(); } <|fim_prefix|>fn main() { uniffi::generate_sca<|fim_middle|>ffolding("<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_suffix|>webc(&container, &rt).await.unwrap() }); if pkg.entrypoint_cmd.is_none() { return Ok(format!("This WEBC ({}) has no entrypoint!", pkg.id)); } let entrypoint = pkg.entrypoint_cmd.clone().unwrap(); let mut stdout = virtual_fs::ArcFile::new(Box::<virtual_fs::BufferFile>::default())...
fim
wasmerio/wasmer
rust
<|fim_suffix|>oc_cfg))] pub mod memory; <|fim_prefix|>#![cfg_att<|fim_middle|>r(docsrs, feature(d<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md use std::{ io::{self, Read, Write}, ptr, slice, }; /// A simple struct consisting of a page-aligned pointer to page-aligned /// and initially-zeroed memory and a l...
fim
wasmerio/wasmer
rust
<|fim_suffix|>; } // `maximum` cannot be set to more than `65536` pages. if let Some(max) = memory.maximum { if max > Pages::max_value() { return Err(MemoryError::MaximumMemoryTooLarge { max_requested: max, max_allowed: Pages::m...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod fd_mmap<|fim_suffix|>dMemory, VMSharedMemory, initialize_memory_with_data}; <|fim_middle|>; mod memories; pub use self::memories::{VMMemory, VMOwne<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>#[cfg(target_o<|fim_suffix|>mory; <|fim_middle|>s = "linux")] pub mod fd_me<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_suffix|> } else { // let mem = VMOwnedMemory::from_definition(ty, style, vm_definition_location)?; // Ok(VMMemory(Box::new(mem))) // } // } // fn create_host_table( // &self, // ty: &wasmer::TableType, // style: &wasmer::vm::TableStyle, // ) ->...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Micro-benchmarks for `StoreId::default()`. //! //! The chunked thread-local allocator amortizes the global atomic //! cross every `CHUNK_SIZE` allocations, so the relevant signals are: //! //! 1. **single-thread hot path** — every call returns from the //! TLS cursor except 1-in-`CHUNK_SIZE` th...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Boxed slices for `PrimaryMap`. use crate::entity::EntityRef; use crate::entity::iter::{Iter, IterMut}; use crate::entity::keys::Keys; use crate::lib::std::boxed::Box; ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>toIter<K, V> { type Item = (K, V); fn next(&mut self) -> Option<Self::Item> { self.enumerate.next().map(|(i, v)| (K::new(i), v)) } fn size_hint(&self) -> (usize, Option<usize>) { self.enumerate.size_hint() } } impl<K: EntityRef, V> DoubleEndedIterator for IntoIter<K,...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! A double-ended iterator over entity references. //! //! When `core::iter::Step` is stabilized, `Keys` could be implemented as a wrapper around //! `core::ops::Range`, but for now, we...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md /// A type wrapping a small integer index should implement `EntityRef` so it can be used as the key /// of an `SecondaryMap` or `SparseMap`. pub trait EntityRef: Copy + Eq ...
fim
wasmerio/wasmer
rust
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Compact representation of `Option<T>` for types with a reserved value. //! //! Small types are often used in tables and linked lists where an //! `Option<T>` is needed. Unfortunately...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Densely numbered entity references as mapping keys. use crate::entity::EntityRef; use crate::entity::boxed_slice::BoxedSlice; use crate::entity::iter::{IntoIter, Iter, ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://gith<|fim_suffix|>} /// Resize the map to have `n` entries by adding default entries as needed. pub fn resize(&mut self, n: usize) { self.elems.resize(n, self.default.clone()); } } impl<K, V> ArchivedSecondary...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! The WebAssembly possible errors use crate::{ExternType, Pages, progress::UserAbort}; use std::io; use thiserror::Error; /// The Serialize error can occur when serializing a /// compiled Module into a binary. #[derive(Error, Debug)] pub enum SerializeError { /// An IO error #[error(transparent...
fim
wasmerio/wasmer
rust
<|fim_prefix|>/// Special exception tag val<|fim_suffix|>AX; <|fim_middle|>ue used for catch_all clauses. pub const CATCH_ALL_TAG_VALUE: i32 = i32::M<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; #[cfg(feature = "detect-wasm-features")] use wasmparser::{Parser, Payload, Validator, WasmFeatures}; /// Controls which experimental features will be enab...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Helper functions and structures for the translation. use crate::entity::entity_impl; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; /* * [todo] xdoardo (on 2024/10/09) * * While updating rkyv fr...
fim
wasmerio/wasmer
rust
/* * ! Remove me once rkyv generates doc-comments for fields or generates an #[allow(missing_docs)] * on their own. */ #![allow(missing_docs)] use crate::indexes::{FunctionIndex, MemoryIndex, TableIndex}; use crate::lib::std::boxed::Box; use crate::types::InitExpr; use rkyv::{Archive, Deserialize as RkyvDeserializ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>his `NativeWasmType`. const WASM_TYPE: Type; } impl NativeWasmType for u32 { const WASM_TYPE: Type = Type::I32; type Abi = Self; } impl NativeWasmType for i32 { const WASM_TYPE: Type = Type::I32; type Abi = Self; } impl NativeWasmType for ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use enum_iterator::Sequence; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use std::fmt; /// The name of a runtime library routine. /// /// This list is likely to grow over time. #[derive( Copy, C...
fim
wasmerio/wasmer
rust
<|fim_suffix|>} } <|fim_prefix|>use crate::{Pages, ValueType}; use core::ops::SubAssign; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; use std::convert::{TryFrom, TryInto}; use std::iter::Sum; use std::ops::{Add, Ad...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Data structure for representing WebAssembly modules in a //! `wasmer::Module`. use crate::entity::{EntityRef, PrimaryMap}; use crate::indexes::SignatureHash; use crate...
fim
wasmerio/wasmer
rust
<|fim_suffix|> hex::encode_upper(&self.as_bytes()[..4]) } } impl Display for ModuleHash { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{}", hex::encode_upper(self.as_bytes())) } } <|fim_prefix|>use std::{ fmt::{self, Display, Formatter}, hash::Hash, }; use rkyv::{...
fim
wasmerio/wasmer
rust
<|fim_suffix|> callback: Arc::new(callback), } } /// Notify the callback about new progress information. pub fn notify(&self, progress: CompilationProgress) -> Result<(), UserAbort> { (self.callback)(progress) } } impl fmt::Debug for CompilationProgressCallback { fn fmt(&self...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{DeserializeError, lib::std::mem}; /// Metadata header which holds an ABI version and the length of the remaining /// metadata. #[repr(C)] #[derive(Clone, Copy)] pub struct MetadataHeader { magic: [u8; 8], version: u32, len: u32, } impl MetadataHeader { /// Current ABI version...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::Sour<|fim_suffix|>exported. /// /// This return value is primarily used for debugging and human-readable /// purposes for things like traps. Note that the exact return value may be /// tweaked over time here and isn't guaranteed to be something in /// particular about a wasm...
fim
wasmerio/wasmer
rust
<|fim_suffix|>oc; pub use trap::TrapInformation; <|fim_prefix|>//! Types for the stack tracing / frames. mod frame; mod sourceloc; mod trap; <|fim_middle|>pub use frame::FrameInfo; pub use sourceloc::SourceL<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code fro<|fim_suffix|>with the given bits. pub fn new(bits: u32) -> Self { Self(bits) } /// Is this the default source location? pub fn is_default(self) -> bool { self == Default::default() } /// Read the bits of this source location. pub...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Types for traps. use crate::CodeOffset; use crate::TrapCode; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; /// Information about trap. #[cfg_attr(feature = "enable-serde", derive(Deserialize, Seri...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use core::fmt::Display; use std::{ cell::Cell, num::NonZeroUsize, sync::atomic::{AtomicUsize, Ordering}, }; /// Unique ID to identify a context. /// /// Every handle to an object managed by a context also contains the ID of the /// context. This is used to check that a handle is always used w...
fim
wasmerio/wasmer
rust
<|fim_suffix|>rtifact-size", derive(loupe::MemoryUsage))] #[repr(u8)] #[rkyv(derive(Debug))] pub enum TableStyle { /// Signatures are stored in the table and checked in the caller. CallerChecksSignature, } <|fim_prefix|>use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSer<|fim_middle|>ialize...
fim
wasmerio/wasmer
rust
//! Target configuration // The clippy::use_self exception is due to a false positive indicating that // `CpuFeature` should be replaced by `Self`. Attaching the allowance to the // type itself has no effect, therefore it's disabled for the whole module. // Feel free to remove this allow attribute once the bug is fixe...
fim
wasmerio/wasmer
rust
<|fim_suffix|> "stk_ovf" => Ok(Self::StackOverflow), "heap_get_oob" => Ok(Self::HeapAccessOutOfBounds), "heap_misaligned" => Ok(Self::HeapMisaligned), "table_get_oob" => Ok(Self::TableAccessOutOfBounds), "icall_null" => Ok(Self::IndirectCallToNull), "bad_...
fim
wasmerio/wasmer
rust
<|fim_suffix|> self.mutability { Mutability::Const => "constant", Mutability::Var => "mutable", }; write!(f, "{} ({})", self.ty, mutability) } } /// A serializable sequence of operators for init expressions in globals, /// element offsets and data offsets. #[derive(Debug, Cl...
fim
wasmerio/wasmer
rust
<|fim_suffix|>:MAX)); assert_eq!(result.unwrap_err(), PageCountOutOfRange); } } <|fim_prefix|>use crate::lib::std::convert::TryFrom; use crate::lib::std::fmt; use crate::lib::std::ops::{Add, Sub}; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; #[cfg(feature = "enable-serde"...
fim
wasmerio/wasmer
rust
/// Check if the provided bytes are wasm-like pub fn is_wasm(bytes: impl AsRef<[u8]>) -> bool { bytes.as_ref().starts_with(b"\0asm") } <|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>use core::{fmt, marker::PhantomData, mem::MaybeUninit}; /// Raw representation of a WebAssembly value. /// /// In most cases you will want to use the type-safe `Value` wrapper instead. #[allow(missing_docs)] #[repr(C)] #[derive(Copy, Clone)] pub union RawValue { pub i32: i32, pub i64: i64, pu...
fim
wasmerio/wasmer
rust
<|fim_prefix|>// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md //! Offsets and sizes of various structs in wasmer-vm's vmcontext //! module. #![deny(rustdoc::broken_intra_doc_links)] use crate::{ FunctionIndex, GlobalIndex, Local...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Used for sharing references to the same file across multiple file systems, //! effectively this is a symbolic link without all the complex path redirection use std::{ io::{self, *}, pin::Pin, sync::{Arc, Mutex}, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncSeek, AsyncWri...
fim
wasmerio/wasmer
rust
<|fim_suffix|>eated_time(&self) -> u64 { let inner = self.inner.lock().unwrap(); inner.created_time() } fn set_times(&mut self, atime: Option<u64>, mtime: Option<u64>) -> crate::Result<()> { let mut inner = self.inner.lock().unwrap(); inner.set_times(atime, mtime) } fn si...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Wraps a cloneable Arc of a file system - in practice this is useful so you //! can pass cloneable file systems with a `Box<dyn FileSystem>` to other //! interfaces use std::{path::Path, sync::Arc}; use crate::*; #[derive(Debug)] pub struct ArcFileSystem { fs: Arc<dyn FileSystem + Send + Sync + ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Used for /dev/zero - infinitely returns zero //! which is useful for commands like `dd if=/dev/zero of=bigfile.img size=1G` use std::io::{self, *}; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; use crate::VirtualFile; #[derive(Debug, Default)...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::random_file::RandomFile; use crate::{FileSystem, MountFileSystem, VirtualFile}; use std::{ path::{Path, Pa<|fim_suffix|>, limiter: Option<DynFsMemoryLimiter>) -> Self { self.memory_limiter = limiter; self } pub fn default_root_dirs(mut self, val: bool) -> Self { ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> { Pin::new(&mut self.tx).poll_flush(cx) } fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> { Pin::new(&mut self.tx).poll_shutdown(cx) ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Used for /dev/zero - infinitely returns zero //! which is useful for commands like `dd if=/dev/zero of=bigfile.img size=1G` use derive_more::Debug; use replace_with::replace_with_or_abort; use std::pin::Pin; use std::task::{Context, Poll}; use std::{ future::Future, io::{self, *}, }; use tok...
fim
wasmerio/wasmer
rust
use super::*; use crate::VirtualFile; /// Wraps a [`VirtualFile`], and also invokes a provided function for each write. /// /// Useful for debugging. #[derive(derive_more::Debug)] pub struct DualWriteFile { inner: Box<dyn VirtualFile + Send + Sync + 'static>, #[allow(clippy::type_complexity)] #[debug(igno...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! When no file system is used by a WebC then this is used as a placeholder - //! as the name suggests it always returns file not found. use std::path::Path; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; use crate::*; <|fim_suffix|> } } impl FileOpener for Empty...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::FileSystem; /// A chain of one or more [`FileSystem`]s. pub trait FileSystems<'a>: 'a { // FIXME(Michael-F-Bryan): Rewrite this to use GATs when we bump the MSRV to // 1.65 or higher. That'll get rid of all the lifetimes and HRTBs. type Iter: IntoIterator<Item = &'a (dyn FileSystem...
fim
wasmerio/wasmer
rust
<|fim_suffix|>_dir(Path::new("foo")), Ok(()), "creating a directory", ); assert_eq!( fs.create_dir(Path::new("foo/bar")), Ok(()), "creating a sub-directory", ); assert!(temp.path().join("foo/bar").exists(), "./foo/bar exists")...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(test)] #[macro_use] extern crate pretty_assertions; use futures::future::BoxFuture; use shared_buffer::OwnedBuffer; use std::any::Any; use std::ffi::OsString; use std::fmt; use std::io; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::pin::Pin; u...
fim
wasmerio/wasmer
rust
<|fim_suffix|>fn deref(&self) -> &Self::Target { &self.data } } impl std::ops::DerefMut for TrackedVec { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.data } } } #[cfg(not(feature = "tracking"))] mod tracked_vec { use crate::FsError; use ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! This module contains the `FileHandle` and `File` //! implementations. They aren't exposed to the public API. Only //! `FileHandle` can be used through the `VirtualFile` trait object. use futures::future::BoxFuture; use shared_buffer::OwnedBuffer; use tokio::io::AsyncRead; use tokio::io::{AsyncSeek, A...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::filesystem::InodeResolution; use super::*; use crate::{FileType, FsError, Metadata, OpenOptionsConfig, Result, VirtualFile}; use shared_buffer::OwnedBuffer; use std::path::Path; use tracing::*; impl FileSystem { /// Inserts a readonly file into the file system that uses copy-on-write /...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! This module contains the [`FileSystem`] type itself. use self::offloaded_file::OffloadBackingStore; use super::*; use crate::{DirEntry, FileType, FsError, Metadata, OpenOptions, ReadDir, Result}; use futures::future::{BoxFuture, Either}; use slab::Slab; use std::collections::VecDeque; use std::conve...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod file; mod file_opener; mod filesystem; mod offloaded_file; mod stdio; use file::{File, FileHandle, ReadOnlyFile}; pub use filesystem::FileSystem; pub use offloaded_file::OffloadBackingStore; #[cfg(not(feature = "js"))] use std::time::{SystemTime, UNIX_EPOCH}; pub use stdio::{Stderr, Stdin, Stdout}; #...
fim
wasmerio/wasmer
rust
<|fim_suffix|> let test_data = std::iter::repeat_n(56u8, 100).collect::<Vec<_>>(); file.write(OffloadWrite::Buffer(&test_data), &mut cursor)?; assert_eq!(file.len(), 100); cursor = 0; let mut result = std::iter::repeat_n(0u8, 100).collect::<Vec<_>>(); file.read(&mut result, &mu...
fim
wasmerio/wasmer
rust
<|fim_suffix|>(&mut buffer).await.is_err(), "cannot read from `stderr`" ); } #[tokio::test] async fn test_write_stderr() { let mut stderr = Stderr { buf: vec![] }; assert!( matches!(stderr.write(b"baz").await, Ok(3)), "writing into `stderr`", ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> read_dir_names(&fs, "/test_rename/bar").contains(&"baz".to_string()), "/bar/baz exists" ); assert!( !read_dir_names(&fs, "/test_rename").contains(&"foo".to_string()), "foo does not exist anymore" ); assert!( read_dir_name...
fim
wasmerio/wasmer
rust
<|fim_suffix|>oll::Ready(Ok(8192)) } } impl CloneableVirtualFile for NullFile {} <|fim_prefix|>//! NullFile is a special file for `/dev/null`, which returns 0 for all //! operations except writing. use std::io::{self, *}; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncSeek, As...
fim
wasmerio/wasmer
rust
<|fim_suffix|>write() { let fs = MemFS::default(); super::write(&fs, "/file.txt", b"Hello, World!") .await .unwrap(); let mut contents = String::new(); fs.new_open_options() .read(true) .open("/file.txt") .unwrap() ...
fim
wasmerio/wasmer
rust
use std::{ collections::HashSet, fmt::Debug, io::{self, SeekFrom}, path::{Path, PathBuf}, pin::Pin, sync::Arc, task::{Context, Poll}, }; use futures::future::BoxFuture; use replace_with::replace_with_or_abort; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf}; use crate::{ Fil...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Wraps a boxed file system with an implemented trait VirtualSystem - this is //! needed so that a `Box<dyn VirtualFileSystem>` can be wrapped in an Arc and //! shared - some of the interfaces pass around a `Box<dyn VirtualFileSystem>` use std::{path::Path, sync::Arc}; use crate::*; #[derive(Debug)] ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use bytes::{Buf, Bytes}; use std::pin::Pin; use std::sync::Arc; use std::sync::Mutex; use std::task::Context; use std::task::Poll; use std::{io::IoSlice, sync::MutexGuard}; use std::{ io::{self, Read, Seek, SeekFrom}, sync::Weak, }; use tokio::sync::mpsc; use tokio::{ io::{AsyncRead, AsyncSeek...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Used for /dev/zero - infinitely returns zero //! which is useful for commands like `dd if=/dev/zero of=bigfile.img size=1G` use std::io::{self, *}; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; use crate::VirtualFile; #[derive(Debug, Default)...
fim
wasmerio/wasmer
rust
<|fim_suffix|>>], ) -> Poll<io::Result<usize>> { Poll::Ready(Ok(bufs.len())) } fn is_write_vectored(&self) -> bool { false } } impl AsyncRead for DeviceFile { fn poll_read( self: Pin<&mut Self>, _cx: &mut Context<'_>, _buf: &mut tokio::io::ReadBuf<'_>, )...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ convert::TryInto, io::{self, Cursor}, pin::Pin, task::{Context, Poll}, }; use shared_buffer::OwnedBuffer; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; use crate::{FsError, VirtualFile}; /// An immutable file backed by an [`OwnedBuffer`]. #[derive(Debug, Clone, PartialEq...
fim
wasmerio/wasmer
rust
use anyhow::anyhow; use futures::future::BoxFuture; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; use std::convert::TryInto; use std::io::{self, Error as IoError, ErrorKind as IoErrorKind, SeekFrom}; use std::path::Path; use std::path::PathBuf; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}...
fim
wasmerio/wasmer
rust
<|fim_suffix|>target: &Path) -> Result<()> { self.fs.create_symlink(source, target) } fn hard_link(&self, source: &Path, target: &Path) -> Result<()> { self.fs.hard_link(source, target) } fn remove_dir(&self, path: &Path) -> Result<()> { self.fs.remove_dir(path) } fn r...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ath.display()))] fn poll_complete(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<u64>> { let result = Pin::new(&mut *self.file).poll_complete(cx); if let Poll::Ready(Err(e)) = &result { tracing::trace!(error = e as &dyn std::error::Error); ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ convert::{TryFrom, TryInto}, io::Cursor, path::{Path, PathBuf}, pin::Pin, result::Result, task::Poll, }; use futures::future::BoxFuture; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; use webc::{ Container, Metadata as WebcMetadata, PathSegmentError, PathSegment...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Used for /dev/zero - infinitely returns zero //! which is useful for commands like `dd if=/dev/zero of=bigfile.img size=1G` use std::{ io::{self, IoSlice, SeekFrom}, iter, pin::Pin, task::{Context, Poll}, }; use tokio::io::{Asy<|fim_suffix|>or ZeroFile { fn start_seek(self: Pin<&...
fim
wasmerio/wasmer
rust
<|fim_suffix|>dlerState>>, } impl ArcInterestHandler { pub fn new(handler: Box<dyn InterestHandler + Send + Sync>) -> Self { Self { state: Arc::new(Mutex::new(ArcInterestHandlerState { handler })), } } } impl InterestHandler for ArcInterestHandler { fn push_interest(&mut self, ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>Type) { if let Some(selector) = self.selector.upgrade() { selector.push_interest(self.token, interest); } } fn drop_internal(&mut self) { if let Some(selector) = self.selector.upgrade() { selector.remove(self.token, None).ok(); } } } #[...
fim
wasmerio/wasmer
rust
<|fim_suffix|>erMapState>>, } impl InterestWakerMap { pub fn add(&self, interest: InterestType, waker: &Waker) { let mut state = self.state.lock().unwrap(); let entries = state.wakers.entry(interest).or_default(); if !entries.iter().any(|w| w.will_wake(waker)) { entries.push(wak...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod arc; #[cfg<|fim_suffix|>:*; <|fim_middle|>(feature = "sys")] mod guard; mod interest; #[cfg(feature = "sys")] mod selector; pub mod waker; pub use waker::block_on; pub use arc::*; #[cfg(feature = "sys")] pub use guard::*; pub use interest::*; #[cfg(feature = "sys")] pub use selector:<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>use mio::{Registry, Token}; use std::{ collections::HashMap, io, sync::{ Arc, Mutex, atomic::{AtomicBool, AtomicUsize, Ordering}, }, }; use crate::{InterestHandler, InterestType}; pub enum SelectorModification { Add { handler: Box<dyn InterestHandler + Send + ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ne()); let mut cx = Context::from_waker(&waker); let mut task = Box::pin(task); loop { match task.as_mut().poll(&mut cx) { Poll::Pending => { parker.park(); } Poll::Ready(ret) => { return ret; } } ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>fn join_multicast_v4( &mut self, multiaddr: std::net::Ipv4Addr, iface: std::net::Ipv4Addr, ) -> Result<()> { self.io_socket_fire_and_forget(RequestType::JoinMulticastV4 { multiaddr, iface }) } fn leave_multicast_v4( &mut self, multiaddr: std::ne...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ualTcpListener for CompositeTcpListener { fn try_accept( &mut self, ) -> crate::Result<(Box<dyn crate::VirtualTcpSocket + Sync>, SocketAddr)> { let mut ret = NetworkError::Unsupported; for port in self.ports.iter_mut() { match port.try_accept() { ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> } let ret = self .socket .send_to(data, addr) .map_err(io_err_into_net_error); match &ret { Ok(0) | Err(NetworkError::WouldBlock) => { if let HandlerGuardState::WakerMap(_, map) = &mut self.handler_guard { ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::multiple_bound_locations)] #[cfg(feature = "remote")] pub mod client; pub mod composite; #[cfg(feature = "host-net")] pub mod host; pub mod loopback; pub mod meta; pub mod ruleset; #[cfg(feature = "remote")] pub mod rx_tx; #[cfg(feature = "remote")] ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::collections::{HashSet, VecDeque}; use std::net::SocketAddr; use std::sync::Mutex; use std::task::{Context, Poll, Waker}; use std::{collections::HashMap, sync::Arc}; use crate::tcp_pair::TcpSocketHalf; use crate::{ InterestHandler, IpAddr, IpCidr, Ipv4Addr, Ipv6Addr, NetworkError, VirtualConn...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::Ipv6Addr; use std::net::SocketAddr; use std::time::Duration; use serde::{Deserialize, Serialize}; pub use super::IpCidr; pub use super::IpRoute; pub use super::NetworkError; pub use super::SocketStatus; pub use super::StreamSecurity; /// Repre...
fim
wasmerio/wasmer
rust
<|fim_prefix|>/// A [`Ruleset`] can be used to specify a whitelist and a blacklist in order to /// control the inbound and outbound traffic of a network. /// /// ## Rule Specification /// Each rule can be expressed like: /// ```text /// <rule_kind>:<rule_action>=<rule_expr> /// /// <rule_kind>: dns, ipv4, ipv6 /// /// ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ pin::Pin, sync::{Arc, Mutex}, task::{Context, Poll, Waker}, }; use crate::Result; use bincode::config; use bytes::Bytes; use futures_util::{Future, Sink, SinkExt, Stream, future::BoxFuture}; #[cfg(feature = "hyper")] use hyper_util::rt::tokio::TokioIo; use serde::Serialize; #[cfg(f...
fim
wasmerio/wasmer
rust
<|fim_suffix|> req_id, ), RequestType::SetMulticastLoopV6(val) => self.process_inner_noop( move |socket| match socket { RemoteAdapterSocket::UdpSocket(s) => s.set_multicast_loop_v6(val), _ => Err(NetworkError::Unsupported), ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{ InterestHandler, NetworkError, SocketStatus, VirtualConnectedSocket, VirtualIoSource, VirtualSocket, VirtualTcpSocket, net_error_into_io_err, }; use bytes::{Buf, Bytes}; use futures_util::Future; use smoltcp::storage::RingBuffer; use std::io::{self}; use std::pin::Pin; use std::sync::...
fim
wasmerio/wasmer
rust