[bun.js] 1/? Implement Response.file

This commit is contained in:
Jarred Sumner
2022-03-21 02:21:51 -07:00
parent 1f93de264f
commit fa343fa8ad
13 changed files with 1108 additions and 108 deletions

View File

@@ -510,6 +510,13 @@ pub const PathOrFileDescriptor = union(Tag) {
pub const Tag = enum { fd, path };
pub fn hash(this: PathOrFileDescriptor) u64 {
return switch (this) {
.path => std.hash.Wyhash.hash(0, this.path.slice()),
.fd => std.hash.Wyhash.hash(0, std.mem.asBytes(&this.fd)),
};
}
pub fn copyToStream(this: PathOrFileDescriptor, flags: FileSystemFlags, auto_close: bool, mode: Mode, allocator: std.mem.Allocator, stream: *Stream) !void {
switch (this) {
.fd => |fd| {