@zigc/lib 0.16.0-dev.3128 → 0.16.0-dev.3133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/aro/backend/Ir/x86/Renderer.zig +3 -3
- package/compiler/resinator/compile.zig +2 -2
- package/package.json +1 -1
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io.zig +963 -2
- package/std/bit_set.zig +22 -6
- package/std/crypto/codecs/base64_hex_ct.zig +2 -2
- package/std/enums.zig +19 -25
- package/std/http/Client.zig +10 -6
|
@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo
|
|
|
21
21
|
const RegisterBitSet = RegisterManager.RegisterBitSet;
|
|
22
22
|
const RegisterClass = struct {
|
|
23
23
|
const gp: RegisterBitSet = blk: {
|
|
24
|
-
var set = RegisterBitSet.
|
|
24
|
+
var set = RegisterBitSet.empty;
|
|
25
25
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);
|
|
26
26
|
break :blk set;
|
|
27
27
|
};
|
|
28
28
|
const x87: RegisterBitSet = blk: {
|
|
29
|
-
var set = RegisterBitSet.
|
|
29
|
+
var set = RegisterBitSet.empty;
|
|
30
30
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);
|
|
31
31
|
break :blk set;
|
|
32
32
|
};
|
|
33
33
|
const sse: RegisterBitSet = blk: {
|
|
34
|
-
var set = RegisterBitSet.
|
|
34
|
+
var set = RegisterBitSet.empty;
|
|
35
35
|
for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);
|
|
36
36
|
break :blk set;
|
|
37
37
|
};
|
|
@@ -2746,7 +2746,7 @@ pub const Compiler = struct {
|
|
|
2746
2746
|
// 1. Any permutation that does not have PRELOAD in it just uses the
|
|
2747
2747
|
// default flags.
|
|
2748
2748
|
const initial_flags = flags.*;
|
|
2749
|
-
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2749
|
+
var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2750
2750
|
for (tokens) |token| {
|
|
2751
2751
|
const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;
|
|
2752
2752
|
flags_set.insert(attribute);
|
|
@@ -2769,7 +2769,7 @@ pub const Compiler = struct {
|
|
|
2769
2769
|
// 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD
|
|
2770
2770
|
// implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`
|
|
2771
2771
|
const shared_set = comptime blk: {
|
|
2772
|
-
var set = std.enums.EnumSet(rc.CommonResourceAttributes).
|
|
2772
|
+
var set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
|
|
2773
2773
|
set.insert(.discardable);
|
|
2774
2774
|
set.insert(.shared);
|
|
2775
2775
|
set.insert(.pure);
|
package/package.json
CHANGED
package/std/Io/File/Reader.zig
CHANGED
|
@@ -309,7 +309,9 @@ fn discard(io_reader: *Io.Reader, limit: Io.Limit) Io.Reader.Error!usize {
|
|
|
309
309
|
return 0;
|
|
310
310
|
};
|
|
311
311
|
const logical_pos = logicalPos(r);
|
|
312
|
-
const
|
|
312
|
+
const bytes_remaining = size - logical_pos;
|
|
313
|
+
if (bytes_remaining == 0) return error.EndOfStream;
|
|
314
|
+
const delta = @min(@intFromEnum(limit), bytes_remaining);
|
|
313
315
|
setLogicalPos(r, logical_pos + delta);
|
|
314
316
|
return delta;
|
|
315
317
|
},
|
package/std/Io/Kqueue.zig
CHANGED
|
@@ -186,7 +186,7 @@ pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
|
|
|
186
186
|
.awaiter = null,
|
|
187
187
|
.queue_next = null,
|
|
188
188
|
.cancel_thread = null,
|
|
189
|
-
.awaiting_completions = .
|
|
189
|
+
.awaiting_completions = .empty,
|
|
190
190
|
};
|
|
191
191
|
const main_thread = &k.threads.allocated[0];
|
|
192
192
|
Thread.self = main_thread;
|
|
@@ -713,7 +713,7 @@ fn concurrent(
|
|
|
713
713
|
.awaiter = null,
|
|
714
714
|
.queue_next = null,
|
|
715
715
|
.cancel_thread = null,
|
|
716
|
-
.awaiting_completions = .
|
|
716
|
+
.awaiting_completions = .empty,
|
|
717
717
|
};
|
|
718
718
|
closure.* = .{
|
|
719
719
|
.kqueue = k,
|
package/std/Io.zig
CHANGED
|
@@ -500,8 +500,8 @@ pub const Batch = struct {
|
|
|
500
500
|
/// Returns the index that will be returned by `next` after the operation completes.
|
|
501
501
|
/// Asserts that no more than `storage.len` operations are active at a time.
|
|
502
502
|
pub fn add(batch: *Batch, operation: Operation) u32 {
|
|
503
|
-
const index = batch.unused.
|
|
504
|
-
batch.addAt(index
|
|
503
|
+
const index = batch.unused.head.toIndex();
|
|
504
|
+
batch.addAt(index, operation);
|
|
505
505
|
return index;
|
|
506
506
|
}
|
|
507
507
|
|
|
@@ -2491,3 +2491,964 @@ test {
|
|
|
2491
2491
|
_ = Semaphore;
|
|
2492
2492
|
_ = @import("Io/test.zig");
|
|
2493
2493
|
}
|
|
2494
|
+
|
|
2495
|
+
/// An implementation of `Io` which simulates a system supporting no `Io` operations.
|
|
2496
|
+
///
|
|
2497
|
+
/// This system has the following properties:
|
|
2498
|
+
/// * Concurrency is unavailable.
|
|
2499
|
+
/// * The stdio handles are pipes whose remote ends are already closed.
|
|
2500
|
+
/// * The filesystem is entirely empty, including that the cwd is no longer present.
|
|
2501
|
+
/// * The filesystem is full, so attempting to create entries always returns `error.NoSpaceLeft`.
|
|
2502
|
+
/// * No entropy source is supported, so `randomSecure` always returns `error.EntropyUnavailable`, and `random` always returns (fills the buffer) with 0.
|
|
2503
|
+
/// * No clocks are supported, so `now` and `sleep` always return `error.UnsupportedClock`.
|
|
2504
|
+
/// * No network is connected, so network operations always return `error.NetworkDown`.
|
|
2505
|
+
pub const failing: std.Io = .{
|
|
2506
|
+
.userdata = null,
|
|
2507
|
+
.vtable = &.{
|
|
2508
|
+
.crashHandler = noCrashHandler,
|
|
2509
|
+
|
|
2510
|
+
.async = noAsync,
|
|
2511
|
+
.concurrent = failingConcurrent,
|
|
2512
|
+
.await = unreachableAwait,
|
|
2513
|
+
.cancel = unreachableCancel,
|
|
2514
|
+
|
|
2515
|
+
.groupAsync = noGroupAsync,
|
|
2516
|
+
.groupConcurrent = failingGroupConcurrent,
|
|
2517
|
+
.groupAwait = unreachableGroupAwait,
|
|
2518
|
+
.groupCancel = unreachableGroupCancel,
|
|
2519
|
+
|
|
2520
|
+
.recancel = unreachableRecancel,
|
|
2521
|
+
.swapCancelProtection = unreachableSwapCancelProtection,
|
|
2522
|
+
.checkCancel = unreachableCheckCancel,
|
|
2523
|
+
|
|
2524
|
+
.futexWait = noFutexWait,
|
|
2525
|
+
.futexWaitUncancelable = noFutexWaitUncancelable,
|
|
2526
|
+
.futexWake = noFutexWake,
|
|
2527
|
+
|
|
2528
|
+
.operate = failingOperate,
|
|
2529
|
+
.batchAwaitAsync = unreachableBatchAwaitAsync,
|
|
2530
|
+
.batchAwaitConcurrent = unreachableBatchAwaitConcurrent,
|
|
2531
|
+
.batchCancel = unreachableBatchCancel,
|
|
2532
|
+
|
|
2533
|
+
.dirCreateDir = failingDirCreateDir,
|
|
2534
|
+
.dirCreateDirPath = failingDirCreateDirPath,
|
|
2535
|
+
.dirCreateDirPathOpen = failingDirCreateDirPathOpen,
|
|
2536
|
+
.dirOpenDir = failingDirOpenDir,
|
|
2537
|
+
.dirStat = failingDirStat,
|
|
2538
|
+
.dirStatFile = failingDirStatFile,
|
|
2539
|
+
.dirAccess = failingDirAccess,
|
|
2540
|
+
.dirCreateFile = failingDirCreateFile,
|
|
2541
|
+
.dirCreateFileAtomic = failingDirCreateFileAtomic,
|
|
2542
|
+
.dirOpenFile = failingDirOpenFile,
|
|
2543
|
+
.dirClose = unreachableDirClose,
|
|
2544
|
+
.dirRead = noDirRead,
|
|
2545
|
+
.dirRealPath = failingDirRealPath,
|
|
2546
|
+
.dirRealPathFile = failingDirRealPathFile,
|
|
2547
|
+
.dirDeleteFile = failingDirDeleteFile,
|
|
2548
|
+
.dirDeleteDir = failingDirDeleteDir,
|
|
2549
|
+
.dirRename = failingDirRename,
|
|
2550
|
+
.dirRenamePreserve = failingDirRenamePreserve,
|
|
2551
|
+
.dirSymLink = failingDirSymLink,
|
|
2552
|
+
.dirReadLink = failingDirReadLink,
|
|
2553
|
+
.dirSetOwner = failingDirSetOwner,
|
|
2554
|
+
.dirSetFileOwner = failingDirSetFileOwner,
|
|
2555
|
+
.dirSetPermissions = failingDirSetPermissions,
|
|
2556
|
+
.dirSetFilePermissions = failingDirSetFilePermissions,
|
|
2557
|
+
.dirSetTimestamps = noDirSetTimestamps,
|
|
2558
|
+
.dirHardLink = failingDirHardLink,
|
|
2559
|
+
|
|
2560
|
+
.fileStat = failingFileStat,
|
|
2561
|
+
.fileLength = failingFileLength,
|
|
2562
|
+
.fileClose = unreachableFileClose,
|
|
2563
|
+
.fileWritePositional = failingFileWritePositional,
|
|
2564
|
+
.fileWriteFileStreaming = noFileWriteFileStreaming,
|
|
2565
|
+
.fileWriteFilePositional = noFileWriteFilePositional,
|
|
2566
|
+
.fileReadPositional = failingFileReadPositional,
|
|
2567
|
+
.fileSeekBy = failingFileSeekBy,
|
|
2568
|
+
.fileSeekTo = failingFileSeekTo,
|
|
2569
|
+
.fileSync = failingFileSync,
|
|
2570
|
+
.fileIsTty = unreachableFileIsTty,
|
|
2571
|
+
.fileEnableAnsiEscapeCodes = unreachableFileEnableAnsiEscapeCodes,
|
|
2572
|
+
.fileSupportsAnsiEscapeCodes = unreachableFileSupportsAnsiEscapeCodes,
|
|
2573
|
+
.fileSetLength = failingFileSetLength,
|
|
2574
|
+
.fileSetOwner = failingFileSetOwner,
|
|
2575
|
+
.fileSetPermissions = failingFileSetPermissions,
|
|
2576
|
+
.fileSetTimestamps = noFileSetTimestamps,
|
|
2577
|
+
.fileLock = failingFileLock,
|
|
2578
|
+
.fileTryLock = failingFileTryLock,
|
|
2579
|
+
.fileUnlock = unreachableFileUnlock,
|
|
2580
|
+
.fileDowngradeLock = failingFileDowngradeLock,
|
|
2581
|
+
.fileRealPath = failingFileRealPath,
|
|
2582
|
+
.fileHardLink = failingFileHardLink,
|
|
2583
|
+
|
|
2584
|
+
.fileMemoryMapCreate = failingFileMemoryMapCreate,
|
|
2585
|
+
.fileMemoryMapDestroy = unreachableFileMemoryMapDestroy,
|
|
2586
|
+
.fileMemoryMapSetLength = unreachableFileMemoryMapSetLength,
|
|
2587
|
+
.fileMemoryMapRead = unreachableFileMemoryMapRead,
|
|
2588
|
+
.fileMemoryMapWrite = unreachableFileMemoryMapWrite,
|
|
2589
|
+
|
|
2590
|
+
.processExecutableOpen = failingProcessExecutableOpen,
|
|
2591
|
+
.processExecutablePath = failingProcessExecutablePath,
|
|
2592
|
+
.lockStderr = unreachableLockStderr,
|
|
2593
|
+
.tryLockStderr = noTryLockStderr,
|
|
2594
|
+
.unlockStderr = unreachableUnlockStderr,
|
|
2595
|
+
.processCurrentPath = failingProcessCurrentPath,
|
|
2596
|
+
.processSetCurrentDir = failingProcessSetCurrentDir,
|
|
2597
|
+
.processSetCurrentPath = failingProcessSetCurrentPath,
|
|
2598
|
+
.processReplace = failingProcessReplace,
|
|
2599
|
+
.processReplacePath = failingProcessReplacePath,
|
|
2600
|
+
.processSpawn = failingProcessSpawn,
|
|
2601
|
+
.processSpawnPath = failingProcessSpawnPath,
|
|
2602
|
+
.childWait = unreachableChildWait,
|
|
2603
|
+
.childKill = unreachableChildKill,
|
|
2604
|
+
|
|
2605
|
+
.progressParentFile = failingProgressParentFile,
|
|
2606
|
+
|
|
2607
|
+
.random = noRandom,
|
|
2608
|
+
.randomSecure = failingRandomSecure,
|
|
2609
|
+
|
|
2610
|
+
.now = noNow,
|
|
2611
|
+
.clockResolution = failingClockResolution,
|
|
2612
|
+
.sleep = noSleep,
|
|
2613
|
+
|
|
2614
|
+
.netListenIp = failingNetListenIp,
|
|
2615
|
+
.netAccept = failingNetAccept,
|
|
2616
|
+
.netBindIp = failingNetBindIp,
|
|
2617
|
+
.netConnectIp = failingNetConnectIp,
|
|
2618
|
+
.netListenUnix = failingNetListenUnix,
|
|
2619
|
+
.netConnectUnix = failingNetConnectUnix,
|
|
2620
|
+
.netSocketCreatePair = failingNetSocketCreatePair,
|
|
2621
|
+
.netSend = failingNetSend,
|
|
2622
|
+
.netRead = failingNetRead,
|
|
2623
|
+
.netWrite = failingNetWrite,
|
|
2624
|
+
.netWriteFile = failingNetWriteFile,
|
|
2625
|
+
.netClose = unreachableNetClose,
|
|
2626
|
+
.netShutdown = failingNetShutdown,
|
|
2627
|
+
.netInterfaceNameResolve = failingNetInterfaceNameResolve,
|
|
2628
|
+
.netInterfaceName = unreachableNetInterfaceName,
|
|
2629
|
+
.netLookup = failingNetLookup,
|
|
2630
|
+
},
|
|
2631
|
+
};
|
|
2632
|
+
|
|
2633
|
+
pub fn noCrashHandler(userdata: ?*anyopaque) void {
|
|
2634
|
+
_ = userdata;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
pub fn noAsync(userdata: ?*anyopaque, result: []u8, result_alignment: std.mem.Alignment, context: []const u8, context_alignment: std.mem.Alignment, start: *const fn (context: *const anyopaque, result: *anyopaque) void) ?*AnyFuture {
|
|
2638
|
+
_ = userdata;
|
|
2639
|
+
_ = result_alignment;
|
|
2640
|
+
_ = context_alignment;
|
|
2641
|
+
start(context.ptr, result.ptr);
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
pub fn failingConcurrent(
|
|
2646
|
+
userdata: ?*anyopaque,
|
|
2647
|
+
result_len: usize,
|
|
2648
|
+
result_alignment: std.mem.Alignment,
|
|
2649
|
+
context: []const u8,
|
|
2650
|
+
context_alignment: std.mem.Alignment,
|
|
2651
|
+
start: *const fn (context: *const anyopaque, result: *anyopaque) void,
|
|
2652
|
+
) ConcurrentError!*AnyFuture {
|
|
2653
|
+
_ = userdata;
|
|
2654
|
+
_ = result_len;
|
|
2655
|
+
_ = result_alignment;
|
|
2656
|
+
_ = context;
|
|
2657
|
+
_ = context_alignment;
|
|
2658
|
+
_ = start;
|
|
2659
|
+
return error.ConcurrencyUnavailable;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
pub fn unreachableAwait(
|
|
2663
|
+
userdata: ?*anyopaque,
|
|
2664
|
+
any_future: *AnyFuture,
|
|
2665
|
+
result: []u8,
|
|
2666
|
+
result_alignment: std.mem.Alignment,
|
|
2667
|
+
) void {
|
|
2668
|
+
_ = userdata;
|
|
2669
|
+
_ = any_future;
|
|
2670
|
+
_ = result;
|
|
2671
|
+
_ = result_alignment;
|
|
2672
|
+
unreachable;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
pub fn unreachableCancel(
|
|
2676
|
+
userdata: ?*anyopaque,
|
|
2677
|
+
any_future: *AnyFuture,
|
|
2678
|
+
result: []u8,
|
|
2679
|
+
result_alignment: std.mem.Alignment,
|
|
2680
|
+
) void {
|
|
2681
|
+
_ = userdata;
|
|
2682
|
+
_ = any_future;
|
|
2683
|
+
_ = result;
|
|
2684
|
+
_ = result_alignment;
|
|
2685
|
+
unreachable;
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
pub fn noGroupAsync(
|
|
2689
|
+
userdata: ?*anyopaque,
|
|
2690
|
+
group: *Group,
|
|
2691
|
+
context: []const u8,
|
|
2692
|
+
context_alignment: std.mem.Alignment,
|
|
2693
|
+
start: *const fn (context: *const anyopaque) void,
|
|
2694
|
+
) void {
|
|
2695
|
+
_ = userdata;
|
|
2696
|
+
_ = group;
|
|
2697
|
+
_ = context_alignment;
|
|
2698
|
+
start(context.ptr);
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
pub fn failingGroupConcurrent(
|
|
2702
|
+
userdata: ?*anyopaque,
|
|
2703
|
+
group: *Group,
|
|
2704
|
+
context: []const u8,
|
|
2705
|
+
context_alignment: std.mem.Alignment,
|
|
2706
|
+
start: *const fn (context: *const anyopaque) void,
|
|
2707
|
+
) ConcurrentError!void {
|
|
2708
|
+
_ = userdata;
|
|
2709
|
+
_ = group;
|
|
2710
|
+
_ = context;
|
|
2711
|
+
_ = context_alignment;
|
|
2712
|
+
_ = start;
|
|
2713
|
+
return error.ConcurrencyUnavailable;
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
pub fn unreachableGroupAwait(userdata: ?*anyopaque, group: *Group, token: *anyopaque) Cancelable!void {
|
|
2717
|
+
_ = userdata;
|
|
2718
|
+
_ = group;
|
|
2719
|
+
_ = token;
|
|
2720
|
+
unreachable;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
pub fn unreachableGroupCancel(userdata: ?*anyopaque, group: *Group, token: *anyopaque) void {
|
|
2724
|
+
_ = userdata;
|
|
2725
|
+
_ = group;
|
|
2726
|
+
_ = token;
|
|
2727
|
+
unreachable;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
pub fn unreachableRecancel(userdata: ?*anyopaque) void {
|
|
2731
|
+
_ = userdata;
|
|
2732
|
+
unreachable;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
pub fn unreachableSwapCancelProtection(userdata: ?*anyopaque, new: CancelProtection) CancelProtection {
|
|
2736
|
+
_ = userdata;
|
|
2737
|
+
_ = new;
|
|
2738
|
+
unreachable;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
pub fn unreachableCheckCancel(userdata: ?*anyopaque) Cancelable!void {
|
|
2742
|
+
_ = userdata;
|
|
2743
|
+
unreachable;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
pub fn noFutexWait(userdata: ?*anyopaque, ptr: *const u32, expected: u32, timeout: Timeout) Cancelable!void {
|
|
2747
|
+
_ = userdata;
|
|
2748
|
+
std.debug.assert(ptr.* == expected or timeout != .none);
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
pub fn noFutexWaitUncancelable(userdata: ?*anyopaque, ptr: *const u32, expected: u32) void {
|
|
2752
|
+
_ = userdata;
|
|
2753
|
+
std.debug.assert(ptr.* == expected);
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
pub fn noFutexWake(userdata: ?*anyopaque, ptr: *const u32, max_waiters: u32) void {
|
|
2757
|
+
_ = userdata;
|
|
2758
|
+
_ = ptr;
|
|
2759
|
+
_ = max_waiters;
|
|
2760
|
+
// no-op
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
pub fn failingOperate(userdata: ?*anyopaque, operation: Operation) Cancelable!Operation.Result {
|
|
2764
|
+
_ = userdata;
|
|
2765
|
+
return switch (operation) {
|
|
2766
|
+
.file_read_streaming => .{ .file_read_streaming = error.InputOutput },
|
|
2767
|
+
.file_write_streaming => .{ .file_write_streaming = error.InputOutput },
|
|
2768
|
+
.device_io_control => unreachable,
|
|
2769
|
+
.net_receive => .{ .net_receive = .{ error.NetworkDown, 0 } },
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
pub fn unreachableBatchAwaitAsync(userdata: ?*anyopaque, b: *Batch) Cancelable!void {
|
|
2774
|
+
_ = userdata;
|
|
2775
|
+
_ = b;
|
|
2776
|
+
unreachable;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
pub fn unreachableBatchAwaitConcurrent(userdata: ?*anyopaque, b: *Batch, timeout: Timeout) Batch.AwaitConcurrentError!void {
|
|
2780
|
+
_ = userdata;
|
|
2781
|
+
_ = b;
|
|
2782
|
+
_ = timeout;
|
|
2783
|
+
unreachable;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
pub fn unreachableBatchCancel(userdata: ?*anyopaque, b: *Batch) void {
|
|
2787
|
+
_ = userdata;
|
|
2788
|
+
_ = b;
|
|
2789
|
+
unreachable;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
pub fn failingDirCreateDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirError!void {
|
|
2793
|
+
_ = userdata;
|
|
2794
|
+
_ = dir;
|
|
2795
|
+
_ = sub_path;
|
|
2796
|
+
_ = permissions;
|
|
2797
|
+
return error.NoSpaceLeft;
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
pub fn failingDirCreateDirPath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirPathError!Dir.CreatePathStatus {
|
|
2801
|
+
_ = userdata;
|
|
2802
|
+
_ = dir;
|
|
2803
|
+
_ = sub_path;
|
|
2804
|
+
_ = permissions;
|
|
2805
|
+
return error.NoSpaceLeft;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
pub fn failingDirCreateDirPathOpen(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions, options: Dir.OpenOptions) Dir.CreateDirPathOpenError!Dir {
|
|
2809
|
+
_ = userdata;
|
|
2810
|
+
_ = dir;
|
|
2811
|
+
_ = sub_path;
|
|
2812
|
+
_ = permissions;
|
|
2813
|
+
_ = options;
|
|
2814
|
+
return error.NoSpaceLeft;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
pub fn failingDirOpenDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.OpenOptions) Dir.OpenError!Dir {
|
|
2818
|
+
_ = userdata;
|
|
2819
|
+
_ = dir;
|
|
2820
|
+
_ = sub_path;
|
|
2821
|
+
_ = options;
|
|
2822
|
+
return error.FileNotFound;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
pub fn failingDirStat(userdata: ?*anyopaque, dir: Dir) Dir.StatError!Dir.Stat {
|
|
2826
|
+
_ = userdata;
|
|
2827
|
+
_ = dir;
|
|
2828
|
+
return error.Streaming;
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
pub fn failingDirStatFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.StatFileOptions) Dir.StatFileError!File.Stat {
|
|
2832
|
+
_ = userdata;
|
|
2833
|
+
_ = dir;
|
|
2834
|
+
_ = sub_path;
|
|
2835
|
+
_ = options;
|
|
2836
|
+
return error.FileNotFound;
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
pub fn failingDirAccess(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.AccessOptions) Dir.AccessError!void {
|
|
2840
|
+
_ = userdata;
|
|
2841
|
+
_ = dir;
|
|
2842
|
+
_ = sub_path;
|
|
2843
|
+
_ = options;
|
|
2844
|
+
return error.FileNotFound;
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
pub fn failingDirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: File.CreateFlags) File.OpenError!File {
|
|
2848
|
+
_ = userdata;
|
|
2849
|
+
_ = dir;
|
|
2850
|
+
_ = sub_path;
|
|
2851
|
+
_ = options;
|
|
2852
|
+
return error.NoSpaceLeft;
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
pub fn failingDirCreateFileAtomic(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.CreateFileAtomicOptions) Dir.CreateFileAtomicError!File.Atomic {
|
|
2856
|
+
_ = userdata;
|
|
2857
|
+
_ = dir;
|
|
2858
|
+
_ = sub_path;
|
|
2859
|
+
_ = options;
|
|
2860
|
+
return error.NoSpaceLeft;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
pub fn failingDirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File {
|
|
2864
|
+
_ = userdata;
|
|
2865
|
+
_ = dir;
|
|
2866
|
+
_ = sub_path;
|
|
2867
|
+
_ = flags;
|
|
2868
|
+
return error.FileNotFound;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
pub fn unreachableDirClose(userdata: ?*anyopaque, dirs: []const Dir) void {
|
|
2872
|
+
_ = userdata;
|
|
2873
|
+
_ = dirs;
|
|
2874
|
+
unreachable;
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2877
|
+
pub fn noDirRead(userdata: ?*anyopaque, dir_reader: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
|
|
2878
|
+
_ = userdata;
|
|
2879
|
+
_ = dir_reader;
|
|
2880
|
+
_ = buffer;
|
|
2881
|
+
return 0;
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
pub fn failingDirRealPath(userdata: ?*anyopaque, dir: Dir, out_buffer: []u8) Dir.RealPathError!usize {
|
|
2885
|
+
_ = userdata;
|
|
2886
|
+
_ = dir;
|
|
2887
|
+
_ = out_buffer;
|
|
2888
|
+
return error.FileNotFound;
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
pub fn failingDirRealPathFile(userdata: ?*anyopaque, dir: Dir, path_name: []const u8, out_buffer: []u8) Dir.RealPathFileError!usize {
|
|
2892
|
+
_ = userdata;
|
|
2893
|
+
_ = dir;
|
|
2894
|
+
_ = path_name;
|
|
2895
|
+
_ = out_buffer;
|
|
2896
|
+
return error.FileNotFound;
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
pub fn failingDirDeleteFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void {
|
|
2900
|
+
_ = userdata;
|
|
2901
|
+
_ = dir;
|
|
2902
|
+
_ = sub_path;
|
|
2903
|
+
return error.FileNotFound;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
pub fn failingDirDeleteDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void {
|
|
2907
|
+
_ = userdata;
|
|
2908
|
+
_ = dir;
|
|
2909
|
+
_ = sub_path;
|
|
2910
|
+
return error.FileNotFound;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
pub fn failingDirRename(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8) Dir.RenameError!void {
|
|
2914
|
+
_ = userdata;
|
|
2915
|
+
_ = old_dir;
|
|
2916
|
+
_ = old_sub_path;
|
|
2917
|
+
_ = new_dir;
|
|
2918
|
+
_ = new_sub_path;
|
|
2919
|
+
return error.FileNotFound;
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
pub fn failingDirRenamePreserve(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8) Dir.RenamePreserveError!void {
|
|
2923
|
+
_ = userdata;
|
|
2924
|
+
_ = old_dir;
|
|
2925
|
+
_ = old_sub_path;
|
|
2926
|
+
_ = new_dir;
|
|
2927
|
+
_ = new_sub_path;
|
|
2928
|
+
return error.FileNotFound;
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
pub fn failingDirSymLink(userdata: ?*anyopaque, dir: Dir, target_path: []const u8, sym_link_path: []const u8, flags: Dir.SymLinkFlags) Dir.SymLinkError!void {
|
|
2932
|
+
_ = userdata;
|
|
2933
|
+
_ = dir;
|
|
2934
|
+
_ = target_path;
|
|
2935
|
+
_ = sym_link_path;
|
|
2936
|
+
_ = flags;
|
|
2937
|
+
return error.FileNotFound;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
pub fn failingDirReadLink(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize {
|
|
2941
|
+
_ = userdata;
|
|
2942
|
+
_ = dir;
|
|
2943
|
+
_ = sub_path;
|
|
2944
|
+
_ = buffer;
|
|
2945
|
+
return error.FileNotFound;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
pub fn failingDirSetOwner(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void {
|
|
2949
|
+
_ = userdata;
|
|
2950
|
+
_ = dir;
|
|
2951
|
+
_ = owner;
|
|
2952
|
+
_ = group;
|
|
2953
|
+
return error.FileNotFound;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
pub fn failingDirSetFileOwner(userdata: ?*anyopaque, dir: std.Io.Dir, sub_path: []const u8, owner: ?File.Uid, group: ?File.Gid, options: Dir.SetFileOwnerOptions) Dir.SetFileOwnerError!void {
|
|
2957
|
+
_ = userdata;
|
|
2958
|
+
_ = dir;
|
|
2959
|
+
_ = sub_path;
|
|
2960
|
+
_ = owner;
|
|
2961
|
+
_ = group;
|
|
2962
|
+
_ = options;
|
|
2963
|
+
return error.FileNotFound;
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
pub fn failingDirSetPermissions(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void {
|
|
2967
|
+
_ = userdata;
|
|
2968
|
+
_ = dir;
|
|
2969
|
+
_ = permissions;
|
|
2970
|
+
return error.FileNotFound;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
pub fn failingDirSetFilePermissions(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: File.Permissions, options: Dir.SetFilePermissionsOptions) Dir.SetFilePermissionsError!void {
|
|
2974
|
+
_ = userdata;
|
|
2975
|
+
_ = dir;
|
|
2976
|
+
_ = sub_path;
|
|
2977
|
+
_ = permissions;
|
|
2978
|
+
_ = options;
|
|
2979
|
+
return error.FileNotFound;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
pub fn noDirSetTimestamps(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.SetTimestampsOptions) Dir.SetTimestampsError!void {
|
|
2983
|
+
_ = userdata;
|
|
2984
|
+
_ = dir;
|
|
2985
|
+
_ = sub_path;
|
|
2986
|
+
_ = options;
|
|
2987
|
+
// no-op
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
pub fn failingDirHardLink(userdata: ?*anyopaque, old_dir: Dir, old_sub_path: []const u8, new_dir: Dir, new_sub_path: []const u8, options: Dir.HardLinkOptions) Dir.HardLinkError!void {
|
|
2991
|
+
_ = userdata;
|
|
2992
|
+
_ = old_dir;
|
|
2993
|
+
_ = old_sub_path;
|
|
2994
|
+
_ = new_dir;
|
|
2995
|
+
_ = new_sub_path;
|
|
2996
|
+
_ = options;
|
|
2997
|
+
return error.FileNotFound;
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
pub fn failingFileStat(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
|
|
3001
|
+
_ = userdata;
|
|
3002
|
+
_ = file;
|
|
3003
|
+
return error.Streaming;
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
pub fn failingFileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 {
|
|
3007
|
+
_ = userdata;
|
|
3008
|
+
_ = file;
|
|
3009
|
+
return error.Streaming;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
pub fn unreachableFileClose(userdata: ?*anyopaque, files: []const File) void {
|
|
3013
|
+
_ = userdata;
|
|
3014
|
+
_ = files;
|
|
3015
|
+
unreachable;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
pub fn failingFileWritePositional(userdata: ?*anyopaque, file: File, header: []const u8, data: []const []const u8, splat: usize, offset: u64) File.WritePositionalError!usize {
|
|
3019
|
+
_ = userdata;
|
|
3020
|
+
_ = file;
|
|
3021
|
+
_ = header;
|
|
3022
|
+
_ = offset;
|
|
3023
|
+
for (data[0 .. data.len - 1]) |item| {
|
|
3024
|
+
if (item.len > 0) return error.BrokenPipe;
|
|
3025
|
+
}
|
|
3026
|
+
if (data[data.len - 1].len != 0 and splat != 0) return error.BrokenPipe;
|
|
3027
|
+
return 0;
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
pub fn noFileWriteFileStreaming(userdata: ?*anyopaque, file: File, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit) File.Writer.WriteFileError!usize {
|
|
3031
|
+
_ = userdata;
|
|
3032
|
+
_ = file;
|
|
3033
|
+
_ = header;
|
|
3034
|
+
_ = file_reader;
|
|
3035
|
+
_ = limit;
|
|
3036
|
+
return error.Unimplemented;
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
pub fn noFileWriteFilePositional(userdata: ?*anyopaque, file: File, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit, offset: u64) File.WriteFilePositionalError!usize {
|
|
3040
|
+
_ = userdata;
|
|
3041
|
+
_ = file;
|
|
3042
|
+
_ = header;
|
|
3043
|
+
_ = file_reader;
|
|
3044
|
+
_ = limit;
|
|
3045
|
+
_ = offset;
|
|
3046
|
+
return error.Unimplemented;
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
pub fn failingFileReadPositional(userdata: ?*anyopaque, file: File, data: []const []u8, offset: u64) File.ReadPositionalError!usize {
|
|
3050
|
+
_ = userdata;
|
|
3051
|
+
_ = file;
|
|
3052
|
+
_ = offset;
|
|
3053
|
+
for (data) |item| {
|
|
3054
|
+
if (item.len > 0) return error.InputOutput;
|
|
3055
|
+
}
|
|
3056
|
+
return 0;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
pub fn failingFileSeekBy(userdata: ?*anyopaque, file: File, relative_offset: i64) File.SeekError!void {
|
|
3060
|
+
_ = userdata;
|
|
3061
|
+
_ = file;
|
|
3062
|
+
_ = relative_offset;
|
|
3063
|
+
return error.Unseekable;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
pub fn failingFileSeekTo(userdata: ?*anyopaque, file: File, absolute_offset: u64) File.SeekError!void {
|
|
3067
|
+
_ = userdata;
|
|
3068
|
+
_ = file;
|
|
3069
|
+
_ = absolute_offset;
|
|
3070
|
+
return error.Unseekable;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
pub fn failingFileSync(userdata: ?*anyopaque, file: File) File.SyncError!void {
|
|
3074
|
+
_ = userdata;
|
|
3075
|
+
_ = file;
|
|
3076
|
+
return error.NoSpaceLeft;
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
pub fn unreachableFileIsTty(userdata: ?*anyopaque, file: File) Cancelable!bool {
|
|
3080
|
+
_ = userdata;
|
|
3081
|
+
_ = file;
|
|
3082
|
+
unreachable;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
pub fn unreachableFileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: File) File.EnableAnsiEscapeCodesError!void {
|
|
3086
|
+
_ = userdata;
|
|
3087
|
+
_ = file;
|
|
3088
|
+
unreachable;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
pub fn unreachableFileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: File) Cancelable!bool {
|
|
3092
|
+
_ = userdata;
|
|
3093
|
+
_ = file;
|
|
3094
|
+
unreachable;
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
pub fn failingFileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {
|
|
3098
|
+
_ = userdata;
|
|
3099
|
+
_ = file;
|
|
3100
|
+
_ = length;
|
|
3101
|
+
return error.NonResizable;
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
pub fn failingFileSetOwner(userdata: ?*anyopaque, file: File, owner: ?File.Uid, group: ?File.Gid) File.SetOwnerError!void {
|
|
3105
|
+
_ = userdata;
|
|
3106
|
+
_ = file;
|
|
3107
|
+
_ = owner;
|
|
3108
|
+
_ = group;
|
|
3109
|
+
return error.FileNotFound;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
pub fn failingFileSetPermissions(userdata: ?*anyopaque, file: File, permissions: File.Permissions) File.SetPermissionsError!void {
|
|
3113
|
+
_ = userdata;
|
|
3114
|
+
_ = file;
|
|
3115
|
+
_ = permissions;
|
|
3116
|
+
return error.FileNotFound;
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
pub fn noFileSetTimestamps(userdata: ?*anyopaque, file: File, options: File.SetTimestampsOptions) File.SetTimestampsError!void {
|
|
3120
|
+
_ = userdata;
|
|
3121
|
+
_ = file;
|
|
3122
|
+
_ = options;
|
|
3123
|
+
// no-op
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
pub fn failingFileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!void {
|
|
3127
|
+
_ = userdata;
|
|
3128
|
+
_ = file;
|
|
3129
|
+
_ = lock;
|
|
3130
|
+
return error.FileLocksUnsupported;
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
pub fn failingFileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!bool {
|
|
3134
|
+
_ = userdata;
|
|
3135
|
+
_ = file;
|
|
3136
|
+
_ = lock;
|
|
3137
|
+
return error.FileLocksUnsupported;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
pub fn unreachableFileUnlock(userdata: ?*anyopaque, file: File) void {
|
|
3141
|
+
_ = userdata;
|
|
3142
|
+
_ = file;
|
|
3143
|
+
unreachable;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
pub fn failingFileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!void {
|
|
3147
|
+
_ = userdata;
|
|
3148
|
+
_ = file;
|
|
3149
|
+
// no-op
|
|
3150
|
+
}
|
|
3151
|
+
|
|
3152
|
+
pub fn failingFileRealPath(userdata: ?*anyopaque, file: File, out_buffer: []u8) File.RealPathError!usize {
|
|
3153
|
+
_ = userdata;
|
|
3154
|
+
_ = file;
|
|
3155
|
+
_ = out_buffer;
|
|
3156
|
+
return error.FileNotFound;
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
pub fn failingFileHardLink(userdata: ?*anyopaque, file: File, new_dir: Dir, new_sub_path: []const u8, options: File.HardLinkOptions) File.HardLinkError!void {
|
|
3160
|
+
_ = userdata;
|
|
3161
|
+
_ = file;
|
|
3162
|
+
_ = new_dir;
|
|
3163
|
+
_ = new_sub_path;
|
|
3164
|
+
_ = options;
|
|
3165
|
+
return error.FileNotFound;
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
pub fn failingFileMemoryMapCreate(userdata: ?*anyopaque, file: File, options: File.MemoryMap.CreateOptions) File.MemoryMap.CreateError!File.MemoryMap {
|
|
3169
|
+
_ = userdata;
|
|
3170
|
+
_ = file;
|
|
3171
|
+
_ = options;
|
|
3172
|
+
return error.AccessDenied;
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
pub fn unreachableFileMemoryMapDestroy(userdata: ?*anyopaque, mm: *File.MemoryMap) void {
|
|
3176
|
+
_ = userdata;
|
|
3177
|
+
_ = mm;
|
|
3178
|
+
unreachable;
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
pub fn unreachableFileMemoryMapSetLength(userdata: ?*anyopaque, mm: *File.MemoryMap, new_len: usize) File.MemoryMap.SetLengthError!void {
|
|
3182
|
+
_ = userdata;
|
|
3183
|
+
_ = mm;
|
|
3184
|
+
_ = new_len;
|
|
3185
|
+
unreachable;
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
pub fn unreachableFileMemoryMapRead(userdata: ?*anyopaque, mm: *File.MemoryMap) File.ReadPositionalError!void {
|
|
3189
|
+
_ = userdata;
|
|
3190
|
+
_ = mm;
|
|
3191
|
+
unreachable;
|
|
3192
|
+
}
|
|
3193
|
+
|
|
3194
|
+
pub fn unreachableFileMemoryMapWrite(userdata: ?*anyopaque, mm: *File.MemoryMap) File.WritePositionalError!void {
|
|
3195
|
+
_ = userdata;
|
|
3196
|
+
_ = mm;
|
|
3197
|
+
unreachable;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
pub fn failingProcessExecutableOpen(userdata: ?*anyopaque, flags: File.OpenFlags) std.process.OpenExecutableError!File {
|
|
3201
|
+
_ = userdata;
|
|
3202
|
+
_ = flags;
|
|
3203
|
+
return error.FileNotFound;
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
pub fn failingProcessExecutablePath(userdata: ?*anyopaque, buffer: []u8) std.process.ExecutablePathError!usize {
|
|
3207
|
+
_ = userdata;
|
|
3208
|
+
_ = buffer;
|
|
3209
|
+
return error.FileNotFound;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
pub fn unreachableLockStderr(userdata: ?*anyopaque, terminal_mode: ?Terminal.Mode) Cancelable!LockedStderr {
|
|
3213
|
+
_ = userdata;
|
|
3214
|
+
_ = terminal_mode;
|
|
3215
|
+
unreachable;
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
pub fn noTryLockStderr(userdata: ?*anyopaque, terminal_mode: ?Terminal.Mode) Cancelable!?LockedStderr {
|
|
3219
|
+
_ = userdata;
|
|
3220
|
+
_ = terminal_mode;
|
|
3221
|
+
return null;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
pub fn unreachableUnlockStderr(userdata: ?*anyopaque) void {
|
|
3225
|
+
_ = userdata;
|
|
3226
|
+
unreachable;
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
pub fn failingProcessCurrentPath(userdata: ?*anyopaque, buffer: []u8) std.process.CurrentPathError!usize {
|
|
3230
|
+
_ = userdata;
|
|
3231
|
+
_ = buffer;
|
|
3232
|
+
return error.CurrentDirUnlinked;
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
pub fn failingProcessSetCurrentDir(userdata: ?*anyopaque, dir: Dir) std.process.SetCurrentDirError!void {
|
|
3236
|
+
_ = userdata;
|
|
3237
|
+
_ = dir;
|
|
3238
|
+
return error.FileNotFound;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
pub fn failingProcessSetCurrentPath(userdata: ?*anyopaque, path: []const u8) std.process.SetCurrentPathError!void {
|
|
3242
|
+
_ = userdata;
|
|
3243
|
+
_ = path;
|
|
3244
|
+
return error.FileNotFound;
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
pub fn failingProcessReplace(userdata: ?*anyopaque, options: std.process.ReplaceOptions) std.process.ReplaceError {
|
|
3248
|
+
_ = userdata;
|
|
3249
|
+
_ = options;
|
|
3250
|
+
return error.OperationUnsupported;
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
pub fn failingProcessReplacePath(userdata: ?*anyopaque, dir: Dir, options: std.process.ReplaceOptions) std.process.ReplaceError {
|
|
3254
|
+
_ = userdata;
|
|
3255
|
+
_ = dir;
|
|
3256
|
+
_ = options;
|
|
3257
|
+
return error.OperationUnsupported;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
pub fn failingProcessSpawn(userdata: ?*anyopaque, options: std.process.SpawnOptions) std.process.SpawnError!std.process.Child {
|
|
3261
|
+
_ = userdata;
|
|
3262
|
+
_ = options;
|
|
3263
|
+
return error.OperationUnsupported;
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
pub fn failingProcessSpawnPath(userdata: ?*anyopaque, dir: Dir, options: std.process.SpawnOptions) std.process.SpawnError!std.process.Child {
|
|
3267
|
+
_ = userdata;
|
|
3268
|
+
_ = dir;
|
|
3269
|
+
_ = options;
|
|
3270
|
+
return error.OperationUnsupported;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
pub fn unreachableChildWait(userdata: ?*anyopaque, child: *std.process.Child) std.process.Child.WaitError!std.process.Child.Term {
|
|
3274
|
+
_ = userdata;
|
|
3275
|
+
_ = child;
|
|
3276
|
+
unreachable;
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
pub fn unreachableChildKill(userdata: ?*anyopaque, child: *std.process.Child) void {
|
|
3280
|
+
_ = userdata;
|
|
3281
|
+
_ = child;
|
|
3282
|
+
unreachable;
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
pub fn failingProgressParentFile(userdata: ?*anyopaque) std.Progress.ParentFileError!File {
|
|
3286
|
+
_ = userdata;
|
|
3287
|
+
return error.UnsupportedOperation;
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
pub fn noRandom(userdata: ?*anyopaque, buffer: []u8) void {
|
|
3291
|
+
_ = userdata;
|
|
3292
|
+
@memset(buffer, 0);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
pub fn failingRandomSecure(userdata: ?*anyopaque, buffer: []u8) RandomSecureError!void {
|
|
3296
|
+
_ = userdata;
|
|
3297
|
+
_ = buffer;
|
|
3298
|
+
return error.EntropyUnavailable;
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
pub fn noNow(userdata: ?*anyopaque, clock: Clock) Timestamp {
|
|
3302
|
+
_ = userdata;
|
|
3303
|
+
_ = clock;
|
|
3304
|
+
return .zero;
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
pub fn failingClockResolution(userdata: ?*anyopaque, clock: Clock) Clock.ResolutionError!Duration {
|
|
3308
|
+
_ = userdata;
|
|
3309
|
+
_ = clock;
|
|
3310
|
+
return error.ClockUnavailable;
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
pub fn noSleep(userdata: ?*anyopaque, clock: Timeout) Cancelable!void {
|
|
3314
|
+
_ = userdata;
|
|
3315
|
+
_ = clock;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
pub fn failingNetListenIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.ListenOptions) net.IpAddress.ListenError!net.Socket {
|
|
3319
|
+
_ = userdata;
|
|
3320
|
+
_ = address;
|
|
3321
|
+
_ = options;
|
|
3322
|
+
return error.NetworkDown;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
pub fn failingNetAccept(userdata: ?*anyopaque, listen_fd: net.Socket.Handle, options: net.Server.AcceptOptions) net.Server.AcceptError!net.Socket {
|
|
3326
|
+
_ = userdata;
|
|
3327
|
+
_ = listen_fd;
|
|
3328
|
+
_ = options;
|
|
3329
|
+
return error.NetworkDown;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
pub fn failingNetBindIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.BindOptions) net.IpAddress.BindError!net.Socket {
|
|
3333
|
+
_ = userdata;
|
|
3334
|
+
_ = address;
|
|
3335
|
+
_ = options;
|
|
3336
|
+
return error.NetworkDown;
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
pub fn failingNetConnectIp(userdata: ?*anyopaque, address: *const net.IpAddress, options: net.IpAddress.ConnectOptions) net.IpAddress.ConnectError!net.Socket {
|
|
3340
|
+
_ = userdata;
|
|
3341
|
+
_ = address;
|
|
3342
|
+
_ = options;
|
|
3343
|
+
return error.NetworkDown;
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
pub fn failingNetListenUnix(userdata: ?*anyopaque, address: *const net.UnixAddress, options: net.UnixAddress.ListenOptions) net.UnixAddress.ListenError!net.Socket.Handle {
|
|
3347
|
+
_ = userdata;
|
|
3348
|
+
_ = address;
|
|
3349
|
+
_ = options;
|
|
3350
|
+
return error.NetworkDown;
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
pub fn failingNetConnectUnix(userdata: ?*anyopaque, address: *const net.UnixAddress) net.UnixAddress.ConnectError!net.Socket.Handle {
|
|
3354
|
+
_ = userdata;
|
|
3355
|
+
_ = address;
|
|
3356
|
+
return error.NetworkDown;
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3359
|
+
pub fn failingNetSocketCreatePair(userdata: ?*anyopaque, options: net.Socket.CreatePairOptions) net.Socket.CreatePairError![2]net.Socket {
|
|
3360
|
+
_ = userdata;
|
|
3361
|
+
_ = options;
|
|
3362
|
+
return error.OperationUnsupported;
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
pub fn failingNetSend(userdata: ?*anyopaque, handle: net.Socket.Handle, messages: []net.OutgoingMessage, flags: net.SendFlags) struct { ?net.Socket.SendError, usize } {
|
|
3366
|
+
_ = userdata;
|
|
3367
|
+
_ = handle;
|
|
3368
|
+
_ = messages;
|
|
3369
|
+
_ = flags;
|
|
3370
|
+
return .{ error.NetworkDown, 0 };
|
|
3371
|
+
}
|
|
3372
|
+
|
|
3373
|
+
pub fn failingNetRead(userdata: ?*anyopaque, src: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
|
|
3374
|
+
_ = userdata;
|
|
3375
|
+
_ = src;
|
|
3376
|
+
_ = data;
|
|
3377
|
+
return error.NetworkDown;
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3380
|
+
pub fn failingNetWrite(userdata: ?*anyopaque, dest: net.Socket.Handle, header: []const u8, data: []const []const u8, splat: usize) net.Stream.Writer.Error!usize {
|
|
3381
|
+
_ = userdata;
|
|
3382
|
+
_ = dest;
|
|
3383
|
+
_ = header;
|
|
3384
|
+
_ = data;
|
|
3385
|
+
_ = splat;
|
|
3386
|
+
return error.NetworkDown;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
pub fn failingNetWriteFile(userdata: ?*anyopaque, handle: net.Socket.Handle, header: []const u8, file_reader: *Io.File.Reader, limit: Io.Limit) net.Stream.Writer.WriteFileError!usize {
|
|
3390
|
+
_ = userdata;
|
|
3391
|
+
_ = handle;
|
|
3392
|
+
_ = header;
|
|
3393
|
+
_ = file_reader;
|
|
3394
|
+
_ = limit;
|
|
3395
|
+
return error.NetworkDown;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
pub fn unreachableNetClose(userdata: ?*anyopaque, handle: []const net.Socket.Handle) void {
|
|
3399
|
+
_ = userdata;
|
|
3400
|
+
_ = handle;
|
|
3401
|
+
unreachable;
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
pub fn failingNetShutdown(userdata: ?*anyopaque, handle: net.Socket.Handle, how: net.ShutdownHow) net.ShutdownError!void {
|
|
3405
|
+
_ = userdata;
|
|
3406
|
+
_ = handle;
|
|
3407
|
+
_ = how;
|
|
3408
|
+
return error.NetworkDown;
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
pub fn failingNetInterfaceNameResolve(userdata: ?*anyopaque, name: *const net.Interface.Name) net.Interface.Name.ResolveError!net.Interface {
|
|
3412
|
+
_ = userdata;
|
|
3413
|
+
_ = name;
|
|
3414
|
+
return error.InterfaceNotFound;
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
pub fn unreachableNetInterfaceName(userdata: ?*anyopaque, interface: net.Interface) net.Interface.NameError!net.Interface.Name {
|
|
3418
|
+
_ = userdata;
|
|
3419
|
+
_ = interface;
|
|
3420
|
+
unreachable;
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
pub fn failingNetLookup(userdata: ?*anyopaque, host_name: net.HostName, resolved: *Queue(net.HostName.LookupResult), options: net.HostName.LookupOptions) net.HostName.LookupError!void {
|
|
3424
|
+
_ = userdata;
|
|
3425
|
+
_ = host_name;
|
|
3426
|
+
_ = resolved;
|
|
3427
|
+
_ = options;
|
|
3428
|
+
return error.NetworkDown;
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3431
|
+
test failing {
|
|
3432
|
+
const f: Io = .failing;
|
|
3433
|
+
// file stuff
|
|
3434
|
+
try std.testing.expectError(error.NoSpaceLeft, Dir.createDir(.cwd(), f, "test", .default_dir));
|
|
3435
|
+
try std.testing.expectError(error.NoSpaceLeft, Dir.createFile(.cwd(), f, "test", .{}));
|
|
3436
|
+
try std.testing.expectError(error.FileNotFound, Dir.openDir(.cwd(), f, "test", .{}));
|
|
3437
|
+
try std.testing.expectError(error.FileNotFound, Dir.openFile(.cwd(), f, "test", .{}));
|
|
3438
|
+
try File.writeStreamingAll(.stdout(), f, &.{});
|
|
3439
|
+
try std.testing.expectError(error.AccessDenied, File.MemoryMap.create(f, .stdout(), .{ .len = 0 }));
|
|
3440
|
+
// async stuff
|
|
3441
|
+
const closure = struct {
|
|
3442
|
+
var foo: usize = 0;
|
|
3443
|
+
fn doOp() void {
|
|
3444
|
+
foo = 4;
|
|
3445
|
+
}
|
|
3446
|
+
};
|
|
3447
|
+
var future = f.async(closure.doOp, .{});
|
|
3448
|
+
_ = future.await(f);
|
|
3449
|
+
try std.testing.expect(closure.foo == 4);
|
|
3450
|
+
// random stuff
|
|
3451
|
+
var buffer: [1]u8 = undefined;
|
|
3452
|
+
f.random(&buffer);
|
|
3453
|
+
try std.testing.expect(buffer[0] == 0);
|
|
3454
|
+
}
|
package/std/bit_set.zig
CHANGED
|
@@ -68,16 +68,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
|
|
|
68
68
|
/// The bit mask, as a single integer
|
|
69
69
|
mask: MaskInt,
|
|
70
70
|
|
|
71
|
+
/// Deprecated: use `.empty`.
|
|
71
72
|
/// Creates a bit set with no elements present.
|
|
72
73
|
pub fn initEmpty() Self {
|
|
73
74
|
return .{ .mask = 0 };
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/// Deprecated: use `.full`.
|
|
76
78
|
/// Creates a bit set with all elements present.
|
|
77
79
|
pub fn initFull() Self {
|
|
78
80
|
return .{ .mask = ~@as(MaskInt, 0) };
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
/// A bit set with no elements present.
|
|
84
|
+
pub const empty: Self = .{ .mask = 0 };
|
|
85
|
+
|
|
86
|
+
/// A bit set with all elements present.
|
|
87
|
+
pub const full: Self = .{ .mask = ~@as(MaskInt, 0) };
|
|
88
|
+
|
|
81
89
|
/// Returns the number of bits in this bit set
|
|
82
90
|
pub inline fn capacity(self: Self) usize {
|
|
83
91
|
_ = self;
|
|
@@ -387,11 +395,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
387
395
|
/// Padding bits at the end are undefined.
|
|
388
396
|
masks: [num_masks]MaskInt,
|
|
389
397
|
|
|
398
|
+
/// Deprecated: use `.empty`.
|
|
390
399
|
/// Creates a bit set with no elements present.
|
|
391
400
|
pub fn initEmpty() Self {
|
|
392
401
|
return .{ .masks = [_]MaskInt{0} ** num_masks };
|
|
393
402
|
}
|
|
394
403
|
|
|
404
|
+
/// Deprecated: use `.full`.
|
|
395
405
|
/// Creates a bit set with all elements present.
|
|
396
406
|
pub fn initFull() Self {
|
|
397
407
|
if (num_masks == 0) {
|
|
@@ -401,6 +411,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
401
411
|
}
|
|
402
412
|
}
|
|
403
413
|
|
|
414
|
+
/// A bit set with no elements present.
|
|
415
|
+
pub const empty: Self = .{ .masks = @splat(0) };
|
|
416
|
+
|
|
417
|
+
/// A bit set with all elements present.
|
|
418
|
+
pub const full: Self = .{ .masks = if (num_masks == 0) .{} else ([_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask}) };
|
|
419
|
+
|
|
404
420
|
/// Returns the number of bits in this bit set
|
|
405
421
|
pub inline fn capacity(self: Self) usize {
|
|
406
422
|
_ = self;
|
|
@@ -1633,17 +1649,17 @@ fn fillOdd(set: anytype, len: usize) void {
|
|
|
1633
1649
|
}
|
|
1634
1650
|
|
|
1635
1651
|
fn testPureBitSet(comptime Set: type) !void {
|
|
1636
|
-
const empty = Set.
|
|
1637
|
-
const full = Set.
|
|
1652
|
+
const empty = Set.empty;
|
|
1653
|
+
const full = Set.full;
|
|
1638
1654
|
|
|
1639
1655
|
const even = even: {
|
|
1640
|
-
var bit_set = Set.
|
|
1656
|
+
var bit_set = Set.empty;
|
|
1641
1657
|
fillEven(&bit_set, Set.bit_length);
|
|
1642
1658
|
break :even bit_set;
|
|
1643
1659
|
};
|
|
1644
1660
|
|
|
1645
1661
|
const odd = odd: {
|
|
1646
|
-
var bit_set = Set.
|
|
1662
|
+
var bit_set = Set.empty;
|
|
1647
1663
|
fillOdd(&bit_set, Set.bit_length);
|
|
1648
1664
|
break :odd bit_set;
|
|
1649
1665
|
};
|
|
@@ -1686,8 +1702,8 @@ fn testPureBitSet(comptime Set: type) !void {
|
|
|
1686
1702
|
}
|
|
1687
1703
|
|
|
1688
1704
|
fn testStaticBitSet(comptime Set: type) !void {
|
|
1689
|
-
var a = Set.
|
|
1690
|
-
var b = Set.
|
|
1705
|
+
var a = Set.empty;
|
|
1706
|
+
var b = Set.full;
|
|
1691
1707
|
try testing.expectEqual(@as(usize, 0), a.count());
|
|
1692
1708
|
try testing.expectEqual(@as(usize, Set.bit_length), b.count());
|
|
1693
1709
|
|
|
@@ -93,7 +93,7 @@ pub const hex = struct {
|
|
|
93
93
|
/// The decoder will skip any characters that are in the ignore list.
|
|
94
94
|
/// The ignore list must not contain any valid hexadecimal characters.
|
|
95
95
|
pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
|
|
96
|
-
var ignored_chars = StaticBitSet(256).
|
|
96
|
+
var ignored_chars = StaticBitSet(256).empty;
|
|
97
97
|
for (ignore_chars) |c| {
|
|
98
98
|
switch (c) {
|
|
99
99
|
'0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,
|
|
@@ -269,7 +269,7 @@ pub const base64 = struct {
|
|
|
269
269
|
|
|
270
270
|
/// Creates a new decoder that ignores certain characters.
|
|
271
271
|
pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
|
|
272
|
-
var ignored_chars = StaticBitSet(256).
|
|
272
|
+
var ignored_chars = StaticBitSet(256).empty;
|
|
273
273
|
for (ignore_chars) |c| {
|
|
274
274
|
switch (c) {
|
|
275
275
|
'A'...'Z', 'a'...'z', '0'...'9' => return error.InvalidCharacter,
|
package/std/enums.zig
CHANGED
|
@@ -252,7 +252,7 @@ pub fn EnumSet(comptime E: type) type {
|
|
|
252
252
|
/// The maximum number of items in this set.
|
|
253
253
|
pub const len = Indexer.count;
|
|
254
254
|
|
|
255
|
-
bits: BitSet =
|
|
255
|
+
bits: BitSet = .empty,
|
|
256
256
|
|
|
257
257
|
/// Initializes the set using a struct of bools
|
|
258
258
|
pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
|
|
@@ -278,19 +278,15 @@ pub fn EnumSet(comptime E: type) type {
|
|
|
278
278
|
return result;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
///
|
|
282
|
-
pub
|
|
283
|
-
return .{ .bits = BitSet.initEmpty() };
|
|
284
|
-
}
|
|
281
|
+
/// A set containing no keys.
|
|
282
|
+
pub const empty: Self = .{ .bits = .empty };
|
|
285
283
|
|
|
286
|
-
///
|
|
287
|
-
pub
|
|
288
|
-
return .{ .bits = BitSet.initFull() };
|
|
289
|
-
}
|
|
284
|
+
/// A set containing all possible keys.
|
|
285
|
+
pub const full: Self = .{ .bits = .full };
|
|
290
286
|
|
|
291
287
|
/// Returns a set containing multiple keys.
|
|
292
288
|
pub fn initMany(keys: []const Key) Self {
|
|
293
|
-
var set =
|
|
289
|
+
var set: Self = .empty;
|
|
294
290
|
for (keys) |key| set.insert(key);
|
|
295
291
|
return set;
|
|
296
292
|
}
|
|
@@ -440,7 +436,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
440
436
|
const BitSet = std.StaticBitSet(Indexer.count);
|
|
441
437
|
|
|
442
438
|
/// Bits determining whether items are in the map
|
|
443
|
-
bits: BitSet =
|
|
439
|
+
bits: BitSet = .empty,
|
|
444
440
|
/// Values of items in the map. If the associated
|
|
445
441
|
/// bit is zero, the value is undefined.
|
|
446
442
|
values: [Indexer.count]Value = undefined,
|
|
@@ -475,7 +471,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
475
471
|
/// Consider using EnumArray instead if the map will remain full.
|
|
476
472
|
pub fn initFull(value: Value) Self {
|
|
477
473
|
var result: Self = .{
|
|
478
|
-
.bits =
|
|
474
|
+
.bits = .full,
|
|
479
475
|
.values = undefined,
|
|
480
476
|
};
|
|
481
477
|
@memset(&result.values, value);
|
|
@@ -493,7 +489,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
493
489
|
pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
|
|
494
490
|
@setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
|
|
495
491
|
var result: Self = .{
|
|
496
|
-
.bits =
|
|
492
|
+
.bits = .full,
|
|
497
493
|
.values = undefined,
|
|
498
494
|
};
|
|
499
495
|
inline for (0..Self.len) |i| {
|
|
@@ -687,16 +683,14 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
|
|
|
687
683
|
return self;
|
|
688
684
|
}
|
|
689
685
|
|
|
690
|
-
///
|
|
691
|
-
pub
|
|
692
|
-
return initWithCount(0);
|
|
693
|
-
}
|
|
686
|
+
/// A multiset with a count of zero.
|
|
687
|
+
pub const empty: Self = .initWithCount(0);
|
|
694
688
|
|
|
695
689
|
/// Initializes the multiset with all keys at the
|
|
696
690
|
/// same count.
|
|
697
691
|
pub fn initWithCount(comptime c: CountSize) Self {
|
|
698
692
|
return .{
|
|
699
|
-
.counts =
|
|
693
|
+
.counts = .initDefault(c, .{}),
|
|
700
694
|
};
|
|
701
695
|
}
|
|
702
696
|
|
|
@@ -855,7 +849,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
|
|
|
855
849
|
test EnumMultiset {
|
|
856
850
|
const Ball = enum { red, green, blue };
|
|
857
851
|
|
|
858
|
-
const empty = EnumMultiset(Ball).
|
|
852
|
+
const empty = EnumMultiset(Ball).empty;
|
|
859
853
|
const r0_g1_b2 = EnumMultiset(Ball).init(.{
|
|
860
854
|
.red = 0,
|
|
861
855
|
.green = 1,
|
|
@@ -1162,8 +1156,8 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
|
|
|
1162
1156
|
test "pure EnumSet fns" {
|
|
1163
1157
|
const Suit = enum { spades, hearts, clubs, diamonds };
|
|
1164
1158
|
|
|
1165
|
-
const empty = EnumSet(Suit).
|
|
1166
|
-
const full = EnumSet(Suit).
|
|
1159
|
+
const empty = EnumSet(Suit).empty;
|
|
1160
|
+
const full = EnumSet(Suit).full;
|
|
1167
1161
|
const black = EnumSet(Suit).initMany(&[_]Suit{ .spades, .clubs });
|
|
1168
1162
|
const red = EnumSet(Suit).initMany(&[_]Suit{ .hearts, .diamonds });
|
|
1169
1163
|
|
|
@@ -1224,8 +1218,8 @@ test "pure EnumSet fns" {
|
|
|
1224
1218
|
|
|
1225
1219
|
test "EnumSet empty" {
|
|
1226
1220
|
const E = enum {};
|
|
1227
|
-
const empty = EnumSet(E).
|
|
1228
|
-
const full = EnumSet(E).
|
|
1221
|
+
const empty = EnumSet(E).empty;
|
|
1222
|
+
const full = EnumSet(E).full;
|
|
1229
1223
|
|
|
1230
1224
|
try std.testing.expect(empty.eql(full));
|
|
1231
1225
|
try std.testing.expect(empty.complement().eql(full));
|
|
@@ -1236,13 +1230,13 @@ test "EnumSet empty" {
|
|
|
1236
1230
|
test "EnumSet const iterator" {
|
|
1237
1231
|
const Direction = enum { up, down, left, right };
|
|
1238
1232
|
const diag_move = init: {
|
|
1239
|
-
var move = EnumSet(Direction).
|
|
1233
|
+
var move = EnumSet(Direction).empty;
|
|
1240
1234
|
move.insert(.right);
|
|
1241
1235
|
move.insert(.up);
|
|
1242
1236
|
break :init move;
|
|
1243
1237
|
};
|
|
1244
1238
|
|
|
1245
|
-
var result = EnumSet(Direction).
|
|
1239
|
+
var result = EnumSet(Direction).empty;
|
|
1246
1240
|
var it = diag_move.iterator();
|
|
1247
1241
|
while (it.next()) |dir| {
|
|
1248
1242
|
result.insert(dir);
|
package/std/http/Client.zig
CHANGED
|
@@ -1133,7 +1133,16 @@ pub const Request = struct {
|
|
|
1133
1133
|
pub fn receiveHead(r: *Request, redirect_buffer: []u8) ReceiveHeadError!Response {
|
|
1134
1134
|
var aux_buf = redirect_buffer;
|
|
1135
1135
|
while (true) {
|
|
1136
|
-
|
|
1136
|
+
// This while loop is for handling redirects, which means the request's
|
|
1137
|
+
// connection may be different than the previous iteration. However, it
|
|
1138
|
+
// is still guaranteed to be non-null with each iteration of this loop.
|
|
1139
|
+
const connection = r.connection.?;
|
|
1140
|
+
|
|
1141
|
+
const head_buffer = r.reader.receiveHead() catch |err| {
|
|
1142
|
+
// Failure here means the connection can no longer be reused.
|
|
1143
|
+
connection.closing = true;
|
|
1144
|
+
return err;
|
|
1145
|
+
};
|
|
1137
1146
|
const response: Response = .{
|
|
1138
1147
|
.request = r,
|
|
1139
1148
|
.head = Response.Head.parse(head_buffer) catch return error.HttpHeadersInvalid,
|
|
@@ -1147,11 +1156,6 @@ pub const Request = struct {
|
|
|
1147
1156
|
return response; // we're not handling the 100-continue
|
|
1148
1157
|
}
|
|
1149
1158
|
|
|
1150
|
-
// This while loop is for handling redirects, which means the request's
|
|
1151
|
-
// connection may be different than the previous iteration. However, it
|
|
1152
|
-
// is still guaranteed to be non-null with each iteration of this loop.
|
|
1153
|
-
const connection = r.connection.?;
|
|
1154
|
-
|
|
1155
1159
|
if (r.method == .CONNECT and head.status.class() == .success) {
|
|
1156
1160
|
// This connection is no longer doing HTTP.
|
|
1157
1161
|
connection.closing = false;
|