Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
20
30
source
stringclasses
1 value
chunk_index
int64
0
520k
token_count
int32
154
512
content
stringlengths
185
57.5k
rust_dataset_chunk_0
rust_dataset.txt
0
512
========================================== REPOSITORY: actix-web ========================================== --- FILE: actix-web/actix-files/examples/guarded-listing.rs --- use actix_files::Files; use actix_web::{get, guard, middleware, App, HttpServer, Responder}; const EXAMPLES_DIR: &str = concat![env!("CARGO_MANIFES...
rust_dataset_chunk_1
rust_dataset.txt
1
512
<File>, }, Future { #[pin] fut: Fut }, } } impl<F, Fut> fmt::Debug for ChunkedReadFile<F, Fut> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("ChunkedReadFile") } } pub(crate) fn new_chunked_read( size: u64, offset: u64, file: File, read_mode_thres...
rust_dataset_chunk_2
rust_dataset.txt
2
512
self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let mut this = self.as_mut().project(); match this.state.as_mut().project() { ChunkedReadFileStateProj::File { file } => { let size = *this.size; let offset = *this.offset; ...
rust_dataset_chunk_3
rust_dataset.txt
3
512
{ if name.starts_with('.') { return false; } } if let Ok(ref md) = entry.metadata() { let ft = md.file_type(); return ft.is_dir() || ft.is_file() || ft.is_symlink(); } } false } }...
rust_dataset_chunk_4
rust_dataset.txt
4
512
Ok(metadata) = entry.metadata() { if metadata.is_dir() { let _ = write!( body, "<li><a href=\"{}\">{}/</a></li>", encode_file_url!(p), encode_file_name!(entry), ); ...
rust_dataset_chunk_5
rust_dataset.txt
5
512
_PLAIN_UTF_8); assert_eq!(equiv_utf8_text(mime::TEXT_XML), mime::TEXT_XML); assert_eq!(equiv_utf8_text(mime::IMAGE_PNG), mime::IMAGE_PNG); } } --- FILE: actix-web/actix-files/src/error.rs --- use actix_web::{http::StatusCode, ResponseError}; use derive_more::Display; /// Errors which can occur wh...
rust_dataset_chunk_6
rust_dataset.txt
6
512
http::header::DispositionType, HttpRequest, }; use futures_core::future::LocalBoxFuture; use crate::{ directory_listing, named, service::{FilesService, FilesServiceInner}, Directory, DirectoryRenderer, HttpNewService, MimeOverride, PathFilter, }; /// Static files handling service. /// /// `Files` ...
rust_dataset_chunk_7
rust_dataset.txt
7
512
#[derive(Debug)] pub struct FilesDirs(Vec<PathBuf>); impl FilesDirs { fn canonicalize(self) -> Vec<PathBuf> { self.0 .into_iter() .map(|orig_dir| match orig_dir.canonicalize() { Ok(canon_dir) => canon_dir, Err(_) => { log::error!("...
rust_dataset_chunk_8
rust_dataset.txt
8
512
} } impl<P, const N: usize> From<&[P; N]> for FilesDirs where P: Clone + Into<PathBuf>, { fn from(dirs: &[P; N]) -> Self { Self(dirs.iter().cloned().map(Into::into).collect()) } } impl<P> From<&[P]> for FilesDirs where P: Clone + Into<PathBuf>, { fn from(dirs: &[P]) -> Self { S...
rust_dataset_chunk_9
rust_dataset.txt
9
512
blocking filesystem operations. /// The number of running threads is adjusted over time as needed, up to a maximum of 512 times /// the number of server [workers](actix_web::HttpServer::workers), by default. pub fn new<T: Into<FilesDirs>>(mount_path: &str, serve_from: T) -> Files { Files { ...
rust_dataset_chunk_10
rust_dataset.txt
10
512
MIME override callback. pub fn mime_override<F>(mut self, f: F) -> Self where F: Fn(&mime::Name<'_>) -> DispositionType + 'static, { self.mime_override = Some(Rc::new(f)); self } /// Sets path filtering closure. /// /// The path provided to the closure is relative t...
rust_dataset_chunk_11
rust_dataset.txt
11
512
pub fn index_file<T: Into<String>>(mut self, index: T) -> Self { self.index = Some(index.into()); self } /// Sets the size threshold that determines file read mode (sync/async). /// /// When a file is smaller than the threshold (bytes), the reader will use synchronous /// (blocking...
rust_dataset_chunk_12
rust_dataset.txt
12
512
/// Files::new("/","/my/site/files") /// .guard(Header("Host", "example.com")) /// ); /// ``` pub fn guard<G: Guard + 'static>(mut self, guard: G) -> Self { self.guards.push(Rc::new(guard)); self } /// Specifies guard to check before fetching directory listings o...
rust_dataset_chunk_13
rust_dataset.txt
13
512
: F) -> Self where F: IntoServiceFactory<U, ServiceRequest>, U: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error> + 'static, { // create and configure default resource self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory...
rust_dataset_chunk_14
rust_dataset.txt
14
512
, renderer: self.renderer.clone(), mime_override: self.mime_override.clone(), path_filter: self.path_filter.clone(), file_flags: self.file_flags, guards: self.use_guards.clone(), hidden_files: self.hidden_files, try_compressed: self.try...
rust_dataset_chunk_15
rust_dataset.txt
15
512
Files; //! //! let app = App::new() //! .service(Files::new("/static", ".").prefer_utf8(true)); //! ``` #![warn(missing_docs, missing_debug_implementations)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_cfg))] u...
rust_dataset_chunk_16
rust_dataset.txt
16
512
web::{self, Bytes}, App, HttpResponse, Responder, }; use super::*; use crate::named::File; #[tokio::test(flavor = "local")] async fn test_file_extension_to_mime() { let m = file_extension_to_mime(""); assert_eq!(m, mime::APPLICATION_OCTET_STREAM); let m = file_ext...
rust_dataset_chunk_17
rust_dataset.txt
17
512
::to_bytes(resp.into_body()).await.unwrap().is_empty(), "POST with matching If-None-Match {value} should have an empty body" ); } } #[tokio::test(flavor = "local")] async fn test_if_modified_since_get_and_head() { let file = NamedFile::open("Cargo.toml").unwrap()...
rust_dataset_chunk_18
rust_dataset.txt
18
512
::NOT_MODIFIED); } #[tokio::test(flavor = "local")] async fn test_if_modified_since_without_if_none_match_same() { let file = NamedFile::open("Cargo.toml").unwrap(); let since = file.last_modified().unwrap(); let req = TestRequest::default() .insert_header((header::IF_M...
rust_dataset_chunk_19
rust_dataset.txt
19
512
(flavor = "local")] async fn test_if_unmodified_since() { let file = NamedFile::open("Cargo.toml").unwrap(); let since = file.last_modified().unwrap(); let req = TestRequest::default() .insert_header((header::IF_UNMODIFIED_SINCE, since)) .to_http_request(); l...
rust_dataset_chunk_20
rust_dataset.txt
20
512
.toml\"" ); let file = NamedFile::open("Cargo.toml") .unwrap() .disable_content_disposition(); let req = TestRequest::default().to_http_request(); let resp = file.respond_to(&req); assert!(resp.headers().get(header::CONTENT_DISPOSITION).is_none()); } ...
rust_dataset_chunk_21
rust_dataset.txt
21
512
} let req = TestRequest::default().to_http_request(); let resp = file.respond_to(&req); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "image/png" ); assert_eq!( resp.headers().get(header::CONTENT_DISPOSITION).unwrap(),...
rust_dataset_chunk_22
rust_dataset.txt
22
512
resp.headers().get(header::CONTENT_DISPOSITION).unwrap(), "attachment; filename=\"test.binary\"" ); } #[allow(deprecated)] #[tokio::test(flavor = "local")] async fn status_code_customize_same_output() { let file1 = NamedFile::open("Cargo.toml") .unwra...
rust_dataset_chunk_23
rust_dataset.txt
23
512
.get(header::CONTENT_DISPOSITION) .expect("To have CONTENT_DISPOSITION"); let content_disposition = content_disposition .to_str() .expect("Convert CONTENT_DISPOSITION to str"); assert_eq!(content_disposition, "attachment; filename=\"Cargo.toml\""); } #[tokio...
rust_dataset_chunk_24
rust_dataset.txt
24
512
*/10" ); assert!( body::to_bytes(response.into_body()) .await .unwrap() .is_empty(), "Range {range:?} should have an empty response body" ); } } #[tokio::test(flavor = "local...
rust_dataset_chunk_25
rust_dataset.txt
25
512
_none_match_before_range() { let req = TestRequest::get().to_http_request(); let resp = NamedFile::open("Cargo.toml").unwrap().into_response(&req); let etag = resp.headers().get(header::ETAG).unwrap().clone(); for range in ["bytes=999999999-", "bytes=0-9"] { let req = TestRe...
rust_dataset_chunk_26
rust_dataset.txt
26
512
"BYTES=2-4", "bYtEs=2-4", "bytes=2-4"] { let req = TestRequest::get() .insert_header((header::RANGE, range)) .to_http_request(); let response = NamedFile::open(file.path()).unwrap().into_response(&req); assert_eq!( response.status(), ...
rust_dataset_chunk_27
rust_dataset.txt
27
512
a validator"] { let file = NamedFile::open("Cargo.toml").unwrap(); let content = fs::read("Cargo.toml").unwrap(); let req = TestRequest::default() .insert_header((header::RANGE, "bytes=0-9")) .insert_header((header::IF_RANGE, stale)) ...
rust_dataset_chunk_28
rust_dataset.txt
28
512
("/tests/test.binary") .insert_header((header::RANGE, range)) .send() .await .unwrap(); assert_eq!(response.status(), StatusCode::RANGE_NOT_SATISFIABLE); let content_range = response.headers().get(header::CONTENT_RANGE).unwrap(); ...
rust_dataset_chunk_29
rust_dataset.txt
29
512
")] async fn test_named_file_content_length_headers() { let srv = actix_test::start(|| App::new().service(Files::new("/", "."))); // Valid range header let response = srv .get("/tests/test.binary") .insert_header((header::RANGE, "bytes=10-20")) .send() ...
rust_dataset_chunk_30
rust_dataset.txt
30
512
= test::call_service(&srv, request).await; assert_eq!(response.status(), StatusCode::OK); let bytes = test::read_body(response).await; let data = web::Bytes::from(fs::read("tests/test space.binary").unwrap()); assert_eq!(bytes, data); } #[cfg(not(target_os = "windows"))] #...
rust_dataset_chunk_31
rust_dataset.txt
31
512
test(flavor = "local")] async fn test_files_guards() { let srv = test::init_service( App::new().service(Files::new("/", ".").method_guard(guard::Post())), ) .await; let req = TestRequest::default() .uri("/Cargo.toml") .method(Method::POST) ...
rust_dataset_chunk_32
rust_dataset.txt
32
512
open("Cargo.toml").unwrap(); let resp = file.respond_to(&req); assert_eq!(resp.status(), StatusCode::OK); } #[tokio::test(flavor = "local")] async fn test_static_files() { let srv = test::init_service(App::new().service(Files::new("/", ".").show_files_listing())).await; ...
rust_dataset_chunk_33
rust_dataset.txt
33
512
index present with permanent redirect let srv = test::init_service( App::new().service( Files::new("/", ".") .index_file("test.png") .redirect_to_slash_directory() .with_permanent_redirect(), ), ) ...
rust_dataset_chunk_34
rust_dataset.txt
34
512
let resp = test::call_service(&service, req).await; assert_eq!(resp.status(), StatusCode::OK); } #[tokio::test(flavor = "local")] async fn test_static_files_empty_directories() { let service = Files::new("/", Vec::<PathBuf>::new()) .new_service(()) .await ...
rust_dataset_chunk_35
rust_dataset.txt
35
512
io::test(flavor = "local")] async fn test_static_files_multiple_directories_file_as_parent_falls_back() { let first_dir = tempfile::tempdir().unwrap(); let second_dir = tempfile::tempdir().unwrap(); fs::write(first_dir.path().join("assets"), "file").unwrap(); fs::create_dir(second_d...
rust_dataset_chunk_36
rust_dataset.txt
36
512
dir().unwrap(); fs::create_dir(first_dir.path().join("nested")).unwrap(); fs::create_dir(second_dir.path().join("nested")).unwrap(); fs::write( second_dir.path().join("nested").join("index.html"), "second index", ) .unwrap(); let service = Files:...
rust_dataset_chunk_37
rust_dataset.txt
37
512
.path()) .index_file("index.html\0") .show_files_listing() .new_service(()) .await .unwrap(); let req = TestRequest::with_uri("/").to_srv_request(); let resp = test::call_service(&service, req).await; assert_eq!(resp.status(), StatusCo...
rust_dataset_chunk_38
rust_dataset.txt
38
512
_response(HttpResponse::Ok().body("default content"))) }) .new_service(()) .await .unwrap(); let req = TestRequest::with_uri("/missing").to_srv_request(); let resp = test::call_service(&st, req).await; assert_eq!(resp.status(), StatusCode::OK); ...
rust_dataset_chunk_39
rust_dataset.txt
39
512
= TestRequest::get().uri("/test/").to_request(); let res = test::call_service(&srv, req).await; assert_eq!(res.status(), StatusCode::OK); let bytes = test::read_body(res).await; let data = Bytes::from(fs::read("Cargo.toml").unwrap()); assert_eq!(bytes, data); // nonexi...
rust_dataset_chunk_40
rust_dataset.txt
40
512
{ write!(&mut buf, "%{:02X}", c).unwrap(); buf }); fs::File::create(temp_dir.path().join(filename)).unwrap(); let srv = test::init_service(App::new().service(Files::new("/", temp_dir.path()))).await; let req = TestRequest::get() .uri(&fo...
rust_dataset_chunk_41
rust_dataset.txt
41
512
let factory = NamedFile::open("Cargo.toml").unwrap(); let srv = test::init_service(App::new().default_service(factory)).await; for route in ["/foobar", "/baz", "/"].iter() { let req = TestRequest::get().uri(route).to_request(); let res = test::call_service(&srv, req).awa...
rust_dataset_chunk_42
rust_dataset.txt
42
512
resp.status(), StatusCode::OK); assert_eq!( resp.headers().get(header::CONTENT_TYPE).unwrap(), "text/x-rust" ); // Show files listing, otherwise. let req = TestRequest::default().uri("/tests").to_srv_request(); let resp = test::call_service(&service, req)...
rust_dataset_chunk_43
rust_dataset.txt
43
512
the whole file name: {href}" ); } for (name, href) in cases { let text = v_htmlescape::escape_fmt(name); assert!(body.contains(&format!("<a href=\"{href}\">{text}</a>"))); } } #[tokio::test(flavor = "local")] async fn test_directory_listing_nest...
rust_dataset_chunk_44
rust_dataset.txt
44
512
Response::Ok().body("default content"))) }) .path_filter(|path, _| path.extension() == Some("png".as_ref())) .new_service(()) .await .unwrap(); let req = TestRequest::with_uri("/Cargo.toml").to_srv_request(); let resp = test::call_service(&st, ...
rust_dataset_chunk_45
rust_dataset.txt
45
512
# Ok(()) /// # } /// ``` /// /// They can also be returned from handlers: /// ``` /// use actix_web::{Responder, get}; /// use actix_files::NamedFile; /// /// #[get("/")] /// async fn index() -> impl Responder { /// NamedFile::open("./static/index.html") /// } /// ``` #[derive(Debug, Deref, DerefMut)] pub struct N...
rust_dataset_chunk_46
rust_dataset.txt
46
512
mut escaped = String::with_capacity(escaped_len); for ch in filename.chars() { match ch { '\n' => escaped.push_str("%0A"), // \n line break '\x0B' => escaped.push_str("%0B"), // \v vertical tab '\x0C' => escaped.push_str("%0C"), // \f form feed ...
rust_dataset_chunk_47
rust_dataset.txt
47
512
{ path, file, content_type, content_disposition, md, modified, encoding, status_code: StatusCode::OK, flags: Flags::default(), read_mode_threshold: 0, }) } /// Attempts to open a fil...
rust_dataset_chunk_48
rust_dataset.txt
48
512
that the content is not already using a compressed /// representation and may be subject to compression downstream. #[inline] pub fn content_encoding(&self) -> Option<ContentEncoding> { self.encoding } /// Set response status code. #[deprecated(since = "0.7.0", note = "Prefer `Responde...
rust_dataset_chunk_49
rust_dataset.txt
49
512
file read mode (sync/async). /// /// When a file is smaller than the threshold (bytes), the reader will use synchronous /// (blocking) file reads. For larger files, it switches to async reads to avoid blocking the /// main thread. /// /// Tweaking this value according to your expected usage may...
rust_dataset_chunk_50
rust_dataset.txt
50
512
_index()) } #[cfg(not(any(unix, windows)))] { 0 } }; // Don't panic for pre-epoch modification times. Encode the timestamp as seconds and // sub-second nanoseconds relative to the UNIX epoch, allowi...
rust_dataset_chunk_51
rust_dataset.txt
51
512
CONTENT_TYPE, ct.to_string())); if self.flags.contains(Flags::CONTENT_DISPOSITION) { res.insert_header(( header::CONTENT_DISPOSITION, self.content_disposition.to_string(), )); } if let Some(current_encoding) = ...
rust_dataset_chunk_52
rust_dataset.txt
52
512
{ false }; let mut res = HttpResponse::build(self.status_code); let ct = if self.flags.contains(Flags::PREFER_UTF8) { equiv_utf8_text(self.content_type.clone()) } else { self.content_type }; res.insert_header((header::CONTENT_TYPE, ...
rust_dataset_chunk_53
rust_dataset.txt
53
512
_header(( header::CONTENT_RANGE, format!("bytes {}-{}/{}", offset, offset + length - 1, self.md.len()), )); } else { res.insert_header((header::CONTENT_RANGE, format!("bytes */{}", length))); retu...
rust_dataset_chunk_54
rust_dataset.txt
54
512
If-None-Match` header matching `req`. fn none_match(etag: Option<&header::EntityTag>, req: &HttpRequest) -> bool { match req.get_header::<header::IfNoneMatch>() { Some(header::IfNoneMatch::Any) => false, Some(header::IfNoneMatch::Items(ref items)) => { if let Some(some_etag) = etag { ...
rust_dataset_chunk_55
rust_dataset.txt
55
512
= get_content_type_and_disposition(Path::new("sound.mp3")).unwrap(); assert_eq!(cd.disposition, DispositionType::Inline); } #[test] fn special_chars_are_escaped_in_content_disposition_filename() { let (_ct, cd) = get_content_type_and_disposition(Path::new("test\n\x0B\x0C\rnewli...
rust_dataset_chunk_56
rust_dataset.txt
56
512
::ETAG).unwrap(), &etag); assert_eq!( to_bytes(res.into_body()).await.unwrap(), b"other".as_slice() ); } } --- FILE: actix-web/actix-files/src/path_buf.rs --- use std::{ borrow::Cow, path::{Component, Path, PathBuf}, str::FromStr, }; #[expect(deprecated, reason...
rust_dataset_chunk_57
rust_dataset.txt
57
512
: bool) -> Result<Self, UriSegmentError> { Self::parse_path(req.path(), hidden_files) } /// Parse a path, giving the choice of allowing hidden files to be considered valid segments. /// /// Path traversal is guarded by this method. pub fn parse_path(path: &str, hidden_files: bool) -> Result...
rust_dataset_chunk_58
rust_dataset.txt
58
512
(_)), "component `{:?}` is not normal", component ); assert!(i < segment_count); } Ok(PathBufWrap(buf)) } } impl AsRef<Path> for PathBufWrap { fn as_ref(&self) -> &Path { self.0.as_ref() } } #[expect(deprecated, reason = "pre...
rust_dataset_chunk_59
rust_dataset.txt
59
512
true).unwrap().0, PathBuf::from_iter(vec!["test", ".tt"]) ); assert_eq!( PathBufWrap::parse_path("/test/./file.txt", true).map(|t| t.0), Err(UriSegmentError::BadStart('.')) ); } #[test] fn path_traversal() { assert_eq!( PathB...
rust_dataset_chunk_60
rust_dataset.txt
60
512
HttpRangeParseError::InvalidRange => Self::InvalidRange, http_range::HttpRangeParseError::NoOverlap => Self::NoOverlap, } } } #[derive(Debug, Clone, Error)] #[non_exhaustive] pub struct ParseRangeErr(#[error(not(source))] HttpRangeParseError); impl fmt::Display for ParseRangeErr { fn fmt(&...
rust_dataset_chunk_61
rust_dataset.txt
61
512
?; Ok(ranges .iter() .map(|range| HttpRange { start: range.start, length: range.length, }) .collect()) } } #[cfg(test)] mod tests { use super::*; struct T(&'static str, u64, Vec<HttpRange>); #[test] fn test_p...
rust_dataset_chunk_62
rust_dataset.txt
62
512
=A-", 10, vec![]), T("bytes=A- ", 10, vec![]), T("bytes=A-Z", 10, vec![]), T("bytes= -Z", 10, vec![]), T("bytes=5-Z", 10, vec![]), T("bytes=Ran-dom, garbage", 10, vec![]), T("bytes=0x01-0x02", 10, vec![]), T("bytes= ", 10, vec![...
rust_dataset_chunk_63
rust_dataset.txt
63
512
, length: 4, }, ], ), T( "bytes=-5", 10, vec![HttpRange { start: 5, length: 5, }], ), T( "by...
rust_dataset_chunk_64
rust_dataset.txt
64
512
7, length: 2, }, ], ), ]; for t in tests { let header = t.0; let size = t.1; let expected = t.2; let res = HttpRange::parse(header, size); if let Err(err) = res { ...
rust_dataset_chunk_65
rust_dataset.txt
65
512
(crate) default: Option<HttpService>, pub(crate) renderer: Rc<DirectoryRenderer>, pub(crate) mime_override: Option<Rc<MimeOverride>>, pub(crate) path_filter: Option<Rc<PathFilter>>, pub(crate) file_flags: named::Flags, pub(crate) guards: Option<Rc<dyn Guard>>, pub(crate) hidden_files: bool, ...
rust_dataset_chunk_66
rust_dataset.txt
66
512
matches!( component, std::path::Component::Normal(name) if name.as_encoded_bytes().starts_with(b".") ) }) { return Err(io::Error::new(io::ErrorKind::NotFound, "hidden file")); } } #[cfg(not(windows))] ...
rust_dataset_chunk_67
rust_dataset.txt
67
512
, base: PathBuf, path: PathBuf) -> ServiceResponse { let dir = Directory::new(base, path); let (req, _) = req.into_parts(); (self.renderer)(&dir, &req).unwrap_or_else(|err| ServiceResponse::from_err(err, req)) } } impl fmt::Debug for FilesService { fn fmt(&self, f: &mut fmt::Formatter...
rust_dataset_chunk_68
rust_dataset.txt
68
512
!path.is_dir() { if let Some((named_file, encoding)) = find_compressed(&req, &path, &this, directory).await { return Ok(this.serve_named_file_with_encoding(req, named_file, encoding)); } } ...
rust_dataset_chunk_69
rust_dataset.txt
69
512
(), path)); } None => found_unrenderable_dir = true, } } else { match NamedFile::open(&path) { Ok(named_file) => return Ok(this.serve_named_file(req, named_file)), Err(...
rust_dataset_chunk_70
rust_dataset.txt
70
512
COMPRESSION_ENCODINGS .iter() .copied() .map(Encoding::Known) .collect::<Vec<_>>(); // Only move the original content-type/disposition into the chosen compressed file once. let mut content_type = Some(content_type); let mut content_disposition = Some(content_disposition); ...
rust_dataset_chunk_71
rust_dataset.txt
71
512
(), "Short-name lookup should succeed for {path:?}" ); let name = String::from_utf8(output.stdout).unwrap().trim().to_owned(); assert!( !name.is_empty() && !name.starts_with('.'), "Path {path:?} should have a nonempty short name without a leading dot, got {na...
rust_dataset_chunk_72
rust_dataset.txt
72
512
}" ); for uri in [ format!("/{env}"), format!("/{git}/config"), format!("/{git}/"), format!("/{git}/only"), format!("/{git}/empty/"), format!("/{compressed_stem}"), ] { le...
rust_dataset_chunk_73
rust_dataset.txt
73
512
").unwrap().len(); let utf8_txt_br_len = std::fs::metadata("./tests/utf8.txt.br").unwrap().len(); let utf8_txt_gz_len = std::fs::metadata("./tests/utf8.txt.gz").unwrap().len(); let srv = test::init_service(App::new().service(Files::new("/", "./tests").try_compressed())).await; // Select the re...
rust_dataset_chunk_74
rust_dataset.txt
74
512
_uri("/utf8.txt").to_request(); req.headers_mut().insert( header::ACCEPT_ENCODING, header::HeaderValue::from_static("zstd"), ); let res = test::call_service(&srv, req).await; assert_eq!(res.status(), StatusCode::OK); assert_eq!( res.headers().get(header::CONTENT_TYPE), ...
rust_dataset_chunk_75
rust_dataset.txt
75
512
res.headers().get(header::CONTENT_TYPE), Some(&HeaderValue::from_static("text/plain; charset=utf-8")), ); assert_eq!(res.headers().get(header::CONTENT_ENCODING), None); } #[tokio::test(flavor = "local")] async fn test_compression_encodings_multiple_directories() { use actix_web::body::Messa...
rust_dataset_chunk_76
rust_dataset.txt
76
512
req = TestRequest::with_uri("/") .append_header((header::RANGE, "bytes=10-20")) .append_header((header::ACCEPT_ENCODING, "gzip")) .to_request(); let res = test::call_service(&srv, req).await; assert_eq!(res.status(), StatusCode::PARTIAL_CONTENT); assert!(!res.headers().contains_key(...
rust_dataset_chunk_77
rust_dataset.txt
77
512
to panic during ETag/Last-Modified generation set_file_mtime(&path, FileTime::from_unix_time(-60, 0)).unwrap(); let mtime = std::fs::metadata(&path).unwrap().modified().unwrap(); assert!( mtime < UNIX_EPOCH, "fixture mtime should be before UNIX_EPOCH" ); let srv = { let pa...
rust_dataset_chunk_78
rust_dataset.txt
78
512
test(flavor = "local")] async fn head_ignores_valid_range() { assert_range_ignored(Method::HEAD, "bytes=2-4").await; } #[tokio::test(flavor = "local")] async fn head_ignores_unsatisfiable_range() { assert_range_ignored(Method::HEAD, "bytes=100-200").await; } #[tokio::test(flavor = "local")] async fn post_igno...
rust_dataset_chunk_79
rust_dataset.txt
79
512
LOC: AllocProfiler = AllocProfiler::system(); #[divan::bench] fn date_formatting(b: Bencher<'_, '_>) { let now = SystemTime::now(); b.bench(|| { black_box(HttpDate::from(black_box(now)).to_string()); }) } fn main() { divan::main(); } --- FILE: actix-web/actix-http/benches/response-body-comp...
End of preview. Expand in Data Studio

Rust and Docs Training Dataset

A massive, multi-format code and documentation corpus built from 70 major open-source Rust repositories (Including but not limited to datafusion clap tokio egui eza dust fd zoxide redox candle).

Dataset Structure

The dataset is processed using a deterministic token-based chunking pipeline (cl100k_base BPE encoding, fixed 512-token chunks with 0-token overlap) across 70 major open-source Rust repositories, preserving repository headers, file boundaries, crate manifests, and multi-line code blocks.

Each record in the JSONL and Parquet shards contains:

  • id: Unique identifier for the chunk (rust_dataset_chunk_<index>).
  • source: Originating consolidated corpus filename (rust_dataset.txt).
  • chunk_index: Sequential zero-based index of the chunk.
  • token_count: Exact BPE token count for the chunk (512 for full chunks, <512 for the final tail chunk).
  • content: Raw text block containing Rust source code, TOML manifests, or technical documentation.

Corpus Breakdown

  • Source & Manifest Corpus (rust_dataset.txt): 30.78M lines (1.10 GB) extracted repository-by-repository from 70 flagship Rust projects (rust, cargo, tokio, serde, bevy, polars, zed, deno, ruff, uv, servo, redox, candle, and others), ordered within each repository by .rs source files, .toml configuration/manifest files (Cargo.toml), and documentation (.md, .rst, .adoc, README, LICENSE).
  • Shards & Token Totals: 520,141 chunks totaling ~266.3M tokens, distributed across Zstd-compressed Apache Parquet (rust_dataset.parquet, ~237.3 MB), JSONL (rust_dataset.jsonl, ~1.21 GB), and raw uint32 binary token arrays (rust_dataset.bin).

License

Distributed under the Apache-2.0 open-source license.

Downloads last month
-