.dump is not recognized when container is passed as an argument!
Closed this issue · 2 comments
Deleted user commented
This is the rust code
I know dump
is missing some args but it isnot recognized by rust at all!
Why is this? And What is the solution?
fn test<M>(container :&mut Cocoon<'_, M>) -> (){
container.dump();
}
fn main() {
let mut container = Cocoon::new("passw".as_bytes());
test(&mut container);
}
And then I get this
error[E0599]: no method named `dump` found for mutable reference `&mut Cocoon<'_, M>` in the current scope
--> src/main.rs:21:13
|
21 | container.dump();
| ^^^^ method not found in `&mut Cocoon<'_, M>`
fadeevab commented
@square-db Hi! Try this
use std::io::Cursor;
use cocoon::{Cocoon, Creation, Error};
fn test(container: &mut Cocoon<'_, Creation>) -> Result<(), Error> {
let data = b"my secret data".to_vec();
let mut buff = vec![];
let mut file = Cursor::new(&mut buff);
container.dump(data, &mut file)
}
fn main() -> Result<(), Error> {
let mut container = Cocoon::new("passw".as_bytes());
test(&mut container)
}
Originally, I made some methods inaccessible in certain scenarios, e.g. if the cocoon was created with Cocoon::parse_only
method... It turns out to be a little bit more complicated for such cases as yours.
There are Cocoon<'_, Creation>
, Cocoon<'_, Parsing>
and general Cocoon<'_, M>
Deleted user commented
Thanks for your Help