-
Notifications
You must be signed in to change notification settings - Fork 3
File
Sara Tavares edited this page Nov 17, 2022
·
2 revisions
The File is a representation of the files uploaded to the Constellation. A File should reference an accessible location to retrieve the file that has been uploaded.
use warp::constellation::file::File;
fn main() {
let file = File::new("test.txt");
assert_eq!(file.name().as_str(), "test.txt");
}
use warp::constellation::file::File;
fn main() {
let file = File::new("test.txt");
file.set_description("Test File");
assert_eq!(file.description().as_str(), "test file");
}
use warp::constellation::{file::File, item::Item};
fn main() {
let file = File::new("test.txt");
file.set_size(100000);
assert_eq!(file.size(), 100000);
}
use std::io::Cursor;
use warp::constellation::file::{File, Hash};
fn main() {
let file = File::new("test.txt");
let mut cursor = Cursor::new(b"Hello, World!");
file.hash_mut().sha256hash_from_reader(&mut cursor).unwrap();
assert_eq!(file.hash().sha256, Some(String::from("DFFD6021BB2BD5B0AF676290809EC3A53191DD81C7F70A4B28688A362182986F")))
}