cross
was a nice tool for cross-compiling stuff. I don't know if it knows raspi-3 specifically (you might need to know the correct target tripple anyway)
impl<'a> Encode<VipsJpegImage<'a>> for VipsJpegImage<'a> {
fn encode(&self, quality: u8) -> Result<VipsJpegImage<'a>, Box<Error>> {
println!("before unsafe encode");
let mut buf: *mut c_void = null_mut();
let mut result_size: usize = 0;
let img = unsafe {
println!("before jpegsave_buffer");
vips::vips_jpegsave_buffer(
self.img,
&mut buf,
&mut result_size,
"Q\0".as_ptr(),
quality as i32,
NULL_LIST,
);
println!("after jpegsave_buffer");
println!(">>>>> {:#?}", result_size);
println!(">>>>> {:#?}", CStr::from_ptr(buf as *const c_char));
vips::vips_image_new_from_buffer(buf as *const c_void, result_size, NULL_LIST)
};
println!("after unsafe encode");
result(img)
}
}
Hi, I'm facing a segfault issue with libvips bindings. Regardless of the specific use case, I wonder if someone could point out possible issues in the code. most likely it should be something related to the mutable buf
used to write the jpeg output in. If I do run the code multiple times, sometimes a jpeg actually get correctly written there, but quite often it just segfaults. So I guess there may be some source of randomness on where the memory address ends up. I saw this pattern around to pass a void pointer to C functions, but I'm not sure if it is the proper way.
vips_jpegsave_buffer
even before getting to the next function)
super::types::...
?
crate::types
graph.rs
:use super::types::{MyType, MyOtherType};
graph.rs
): use types::{MyType, MyOtherType};
use
the same way in Rust 2018?
imports can only refer to extern crate names passed with --extern
on stable channel (see issue #53130)rustc(E0658)
mod renderer;
use renderer::{LinkedNode, Node};
mod renderer;
use self::renderer::{LinkedNode, Node};
Hello :)
My question is also related to Rust 2018. I'm just trying to understand why it doesn't work :
| - main.rs
| - foo
| - foo.rs
| - bar.rs
From main.rs
:
mod foo;
The compiler give me this message name the file either foo.rs or foo/mod.rs inside the directory "src"
but giving the documentation i can rename mod.rs
by foo.rs
.
src/foo.rs
, not src/foo/foo.rs
| - main.rs
| - foo.rs
| - foo
| - bar.rs
src/foo/mod.rs
also works.
mod.rs
seems to be better in this case for me :)
supermodule.pm
, supermodule/submodule.pm
. But keep using mod.rs
if you like.
struct Foo {
collection: Bar,
}
let obj = Foo {
bar: Bar::new()
}
For example, I have Foo
, which contains Bar
Bar
has a method add
And i want to Foo.add
, was equivalent to call Foo.bar.add
Like Foo extends Bar
in OOP languages.
How to achieve that?
Trait is fit to my functionality, but inside trait i can't use types, only functions :(
pub trait Addible {
// can i add something like this trait SHOULD contain {collection: Bar}
// and use construction like below
fn add(&self, object: Object) -> &Self {
&self::collection::add(object)
}
}
type X<T> = Y<T>
? that should work