Hiro
Hiro
DDeno
Created by Hiro on 9/4/2023 in #help
How to use KV Connect?
Hello there HelloThere Is there any plan an making an STD module for creating a server with proper scheme and types for this protocol? Though maybe my question is wrong and I misunderstood the proper usage for remote backend with KV..?
3 replies
DDeno
Created by Hiro on 4/26/2023 in #help
Property 'openKv' does not exist on type 'typeof Deno'. VSCode
Such as the title say, I cant get the LSP to recognize openKv in the Deno namespace... deno 1.32.5+78b630d (canary, x86_64-apple-darwin) v8 11.2.214.15 typescript 5.0.3 Any idea ?
51 replies
DDeno
Created by Hiro on 1/15/2023 in #help
Pass string to struct FFI
Quick question about Struct-Value feature, what would be the best way to pass *const u8 (or strings) to structs? I am kinda lost after reading the tests to get some examples running, here's what I got working so far :
const lib = Deno.dlopen("./target/debug/libtest_struct.so", {
add: {
parameters: [{struct: ["buffer"] }],
result: "void"
}
})

const buff1 = new TextEncoder().encode("Hello\0").buffer

const ptr = Deno.UnsafePointer.of(buff1);
const struct = new BigUint64Array([BigInt(ptr)]);

lib.symbols.add(struct)
const lib = Deno.dlopen("./target/debug/libtest_struct.so", {
add: {
parameters: [{struct: ["buffer"] }],
result: "void"
}
})

const buff1 = new TextEncoder().encode("Hello\0").buffer

const ptr = Deno.UnsafePointer.of(buff1);
const struct = new BigUint64Array([BigInt(ptr)]);

lib.symbols.add(struct)
use std::ffi;

#[derive(Debug)]
#[repr(C)]
pub struct Point {
pub test: *const u8,
}


#[no_mangle]
pub extern "C" fn add(points: Point) {
let ptr = points.test;
let strtest = unsafe { ffi::CStr::from_ptr(ptr as *const i8) };
println!("strtest: {:?}", strtest);
}
use std::ffi;

#[derive(Debug)]
#[repr(C)]
pub struct Point {
pub test: *const u8,
}


#[no_mangle]
pub extern "C" fn add(points: Point) {
let ptr = points.test;
let strtest = unsafe { ffi::CStr::from_ptr(ptr as *const i8) };
println!("strtest: {:?}", strtest);
}
There must be a beter way of doing this right?
10 replies