#[doc(hidden)]
#[allow(non_snake_case)]
pub unsafe fn _export_run_cabi<T: Guest>(arg0: *mut u8, arg1: usize) -> *mut u8 {
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
let len0 = arg1;
let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0);
let result1 = T::run(_rt::string_lift(bytes0));
let ptr2 = (&raw mut _RET_AREA.0).cast::<u8>();
let vec3 = (result1.into_bytes()).into_boxed_slice();
let ptr3 = vec3.as_ptr().cast::<u8>();
let len3 = vec3.len();
::core::mem::forget(vec3);
*ptr2.add(::core::mem::size_of::<*const u8>()).cast::<usize>() = len3;
*ptr2.add(0).cast::<*mut u8>() = ptr3.cast_mut();
ptr2
}
#[doc(hidden)]
#[allow(non_snake_case)]
pub unsafe fn __post_return_run<T: Guest>(arg0: *mut u8) {
let l0 = *arg0.add(0).cast::<*mut u8>();
let l1 = *arg0.add(::core::mem::size_of::<*const u8>()).cast::<usize>();
_rt::cabi_dealloc(l0, l1, 1);
}
pub trait Guest {
fn run(user_query: _rt::String) -> _rt::String;
}
#[doc(hidden)]
macro_rules! __export_world_memory_agent_cabi {
($ty:ident with_types_in $($path_to_types:tt)*) => {
const _ : () = { #[unsafe (export_name = "run")] unsafe extern "C" fn
export_run(arg0 : * mut u8, arg1 : usize,) -> * mut u8 { unsafe {
$($path_to_types)*:: _export_run_cabi::<$ty > (arg0, arg1) } } #[unsafe
(export_name = "cabi_post_run")] unsafe extern "C" fn _post_return_run(arg0 : *
mut u8,) { unsafe { $($path_to_types)*:: __post_return_run::<$ty > (arg0) } } };
};
}
#[doc(hidden)]
pub(crate) use __export_world_memory_agent_cabi;
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
struct _RetArea([::core::mem::MaybeUninit<u8>; 2 * ::core::mem::size_of::<*const u8>()]);
static mut _RET_AREA: _RetArea = _RetArea(
[::core::mem::MaybeUninit::uninit(); 2 * ::core::mem::size_of::<*const u8>()],
);
#[rustfmt::skip]
#[allow(dead_code, clippy::all)]
pub mod mnemo {
pub mod memory {
#[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)]
pub mod store {
#[used]
#[doc(hidden)]
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
use super::super::super::_rt;
#[derive(Clone)]
pub struct Memory {
pub id: _rt::String,
pub content: _rt::String,
pub score: f32,
}
impl ::core::fmt::Debug for Memory {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("Memory")
.field("id", &self.id)
.field("content", &self.content)
.field("score", &self.score)
.finish()
}
}
#[derive(Clone)]
pub struct Provenance {
pub receipt_id: _rt::String,
pub hmac_key_id: _rt::String,
pub record_count: u32,
}
impl ::core::fmt::Debug for Provenance {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("Provenance")
.field("receipt-id", &self.receipt_id)
.field("hmac-key-id", &self.hmac_key_id)
.field("record-count", &self.record_count)
.finish()
}
}
#[allow(unused_unsafe, clippy::all)]
pub fn recall(query: &str, k: u32) -> _rt::Vec<Memory> {
unsafe {
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
struct RetArea(
[::core::mem::MaybeUninit<
u8,
>; 2 * ::core::mem::size_of::<*const u8>()],
);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2
* ::core::mem::size_of::<*const u8>()],
);
let vec0 = query;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "mnemo:memory/store@0.4.0")]
unsafe extern "C" {
#[link_name = "recall"]
fn wit_import2(_: *mut u8, _: usize, _: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
unsafe extern "C" fn wit_import2(
_: *mut u8,
_: usize,
_: i32,
_: *mut u8,
) {
unreachable!()
}
unsafe { wit_import2(ptr0.cast_mut(), len0, _rt::as_i32(&k), ptr1) };
let l3 = *ptr1.add(0).cast::<*mut u8>();
let l4 = *ptr1
.add(::core::mem::size_of::<*const u8>())
.cast::<usize>();
let base12 = l3;
let len12 = l4;
let mut result12 = _rt::Vec::with_capacity(len12);
for i in 0..len12 {
let base = base12
.add(i * (5 * ::core::mem::size_of::<*const u8>()));
let e12 = {
let l5 = *base.add(0).cast::<*mut u8>();
let l6 = *base
.add(::core::mem::size_of::<*const u8>())
.cast::<usize>();
let len7 = l6;
let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7);
let l8 = *base
.add(2 * ::core::mem::size_of::<*const u8>())
.cast::<*mut u8>();
let l9 = *base
.add(3 * ::core::mem::size_of::<*const u8>())
.cast::<usize>();
let len10 = l9;
let bytes10 = _rt::Vec::from_raw_parts(
l8.cast(),
len10,
len10,
);
let l11 = *base
.add(4 * ::core::mem::size_of::<*const u8>())
.cast::<f32>();
Memory {
id: _rt::string_lift(bytes7),
content: _rt::string_lift(bytes10),
score: l11,
}
};
result12.push(e12);
}
_rt::cabi_dealloc(
base12,
len12 * (5 * ::core::mem::size_of::<*const u8>()),
::core::mem::size_of::<*const u8>(),
);
let result13 = result12;
result13
}
}
#[allow(unused_unsafe, clippy::all)]
pub fn score(mem: &Memory) -> f32 {
unsafe {
let Memory { id: id0, content: content0, score: score0 } = mem;
let vec1 = id0;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let vec2 = content0;
let ptr2 = vec2.as_ptr().cast::<u8>();
let len2 = vec2.len();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "mnemo:memory/store@0.4.0")]
unsafe extern "C" {
#[link_name = "score"]
fn wit_import3(
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: f32,
) -> f32;
}
#[cfg(not(target_arch = "wasm32"))]
unsafe extern "C" fn wit_import3(
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: f32,
) -> f32 {
unreachable!()
}
let ret = unsafe {
wit_import3(
ptr1.cast_mut(),
len1,
ptr2.cast_mut(),
len2,
_rt::as_f32(score0),
)
};
ret
}
}
#[allow(unused_unsafe, clippy::all)]
pub fn cite(mem: &Memory) -> Provenance {
unsafe {
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
struct RetArea(
[::core::mem::MaybeUninit<
u8,
>; 5 * ::core::mem::size_of::<*const u8>()],
);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 5
* ::core::mem::size_of::<*const u8>()],
);
let Memory { id: id0, content: content0, score: score0 } = mem;
let vec1 = id0;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let vec2 = content0;
let ptr2 = vec2.as_ptr().cast::<u8>();
let len2 = vec2.len();
let ptr3 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "mnemo:memory/store@0.4.0")]
unsafe extern "C" {
#[link_name = "cite"]
fn wit_import4(
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: f32,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
unsafe extern "C" fn wit_import4(
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: f32,
_: *mut u8,
) {
unreachable!()
}
unsafe {
wit_import4(
ptr1.cast_mut(),
len1,
ptr2.cast_mut(),
len2,
_rt::as_f32(score0),
ptr3,
)
};
let l5 = *ptr3.add(0).cast::<*mut u8>();
let l6 = *ptr3
.add(::core::mem::size_of::<*const u8>())
.cast::<usize>();
let len7 = l6;
let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7);
let l8 = *ptr3
.add(2 * ::core::mem::size_of::<*const u8>())
.cast::<*mut u8>();
let l9 = *ptr3
.add(3 * ::core::mem::size_of::<*const u8>())
.cast::<usize>();
let len10 = l9;
let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10);
let l11 = *ptr3
.add(4 * ::core::mem::size_of::<*const u8>())
.cast::<i32>();
let result12 = Provenance {
receipt_id: _rt::string_lift(bytes7),
hmac_key_id: _rt::string_lift(bytes10),
record_count: l11 as u32,
};
result12
}
}
}
}
}
#[rustfmt::skip]
mod _rt {
#![allow(dead_code, clippy::all)]
pub use alloc_crate::string::String;
pub use alloc_crate::vec::Vec;
pub fn as_i32<T: AsI32>(t: T) -> i32 {
t.as_i32()
}
pub trait AsI32 {
fn as_i32(self) -> i32;
}
impl<'a, T: Copy + AsI32> AsI32 for &'a T {
fn as_i32(self) -> i32 {
(*self).as_i32()
}
}
impl AsI32 for i32 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u32 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for i16 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u16 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for i8 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for u8 {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for char {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
impl AsI32 for usize {
#[inline]
fn as_i32(self) -> i32 {
self as i32
}
}
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
if cfg!(debug_assertions) {
String::from_utf8(bytes).unwrap()
} else {
String::from_utf8_unchecked(bytes)
}
}
pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) {
if size == 0 {
return;
}
let layout = alloc::Layout::from_size_align_unchecked(size, align);
alloc::dealloc(ptr, layout);
}
pub fn as_f32<T: AsF32>(t: T) -> f32 {
t.as_f32()
}
pub trait AsF32 {
fn as_f32(self) -> f32;
}
impl<'a, T: Copy + AsF32> AsF32 for &'a T {
fn as_f32(self) -> f32 {
(*self).as_f32()
}
}
impl AsF32 for f32 {
#[inline]
fn as_f32(self) -> f32 {
self as f32
}
}
#[cfg(target_arch = "wasm32")]
pub fn run_ctors_once() {
wit_bindgen_rt::run_ctors_once();
}
extern crate alloc as alloc_crate;
pub use alloc_crate::alloc;
}
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! __export_memory_agent_impl {
($ty:ident) => {
self::export!($ty with_types_in self);
};
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
$($path_to_types_root)*:: __export_world_memory_agent_cabi!($ty with_types_in
$($path_to_types_root)*);
};
}
#[doc(inline)]
pub(crate) use __export_memory_agent_impl as export;
#[cfg(target_arch = "wasm32")]
#[unsafe(
link_section = "component-type:wit-bindgen:0.41.0:mnemo:memory@0.4.0:memory-agent:encoded world"
)]
#[doc(hidden)]
#[allow(clippy::octal_escapes)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 391] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x84\x02\x01A\x02\x01\
A\x04\x01B\x0b\x01r\x03\x02ids\x07contents\x05scorev\x04\0\x06memory\x03\0\0\x01\
r\x03\x0areceipt-ids\x0bhmac-key-ids\x0crecord-county\x04\0\x0aprovenance\x03\0\x02\
\x01p\x01\x01@\x02\x05querys\x01ky\0\x04\x04\0\x06recall\x01\x05\x01@\x01\x03mem\
\x01\0v\x04\0\x05score\x01\x06\x01@\x01\x03mem\x01\0\x03\x04\0\x04cite\x01\x07\x03\
\0\x18mnemo:memory/store@0.4.0\x05\0\x01@\x01\x0auser-querys\0s\x04\0\x03run\x01\
\x01\x04\0\x1fmnemo:memory/memory-agent@0.4.0\x04\0\x0b\x12\x01\0\x0cmemory-agen\
t\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10\
wit-bindgen-rust\x060.41.0";
#[inline(never)]
#[doc(hidden)]
pub fn __link_custom_section_describing_imports() {
wit_bindgen_rt::maybe_link_cabi_realloc();
}