I have some struct with data
member, that should implement reference to file bytes before send it to some socket after build:
pub struct Titan<'a> {
pub data: &'a [u8], // <-
pub size: usize,
pub path: String,
pub mime: Option<String>,
pub token: Option<String>,
pub options: Option<HashMap<String, String>>,
}
The size of this data
would be 1 Gb or more, so Vec
is not an option here, that because I have added the reference with lifetime there.
I hope this implementation will not copy all UTF-8 bytes from file into the memory, but not sure it will not copy 1 Gb of the references also, because as understand, references takes more space than u8
or it's not references to every byte (unlike
&[&u8]
) and everything ok here?
p.s. before I've used Glib Bytes, but for now I won't have this c-lang dependency in the new crate.
p.p.s. also, thoughts to replace String
with &str
, but I want just to understand if the data
implemented properly to continue.