@@ -4,30 +4,30 @@ pub const c = @cImport({
44});
55const Allocator = std .mem .Allocator ;
66const Encoder = std .base64 .standard .Encoder ;
7- pub const DynamicBuffer = std .ArrayList (u8 );
8- pub const StaticBuffer = struct {
7+ pub const ResizableBuffer = std .ArrayList (u8 );
8+ pub const FixedBuffer = struct {
99 data : []u8 ,
1010 // How many bytes are used in the buffer.
1111 size : usize ,
1212
13- pub fn init (data : []u8 ) StaticBuffer {
13+ pub fn init (data : []u8 ) FixedBuffer {
1414 return .{ .data = data , .size = 0 };
1515 }
1616
17- pub fn asSlice (self : * StaticBuffer ) []const u8 {
17+ pub fn asSlice (self : * FixedBuffer ) []const u8 {
1818 return self .data [0.. self .size ];
1919 }
2020};
2121
22- pub const StaticContext = struct {
23- buffer : StaticBuffer ,
22+ pub const FixedWriteContext = struct {
23+ buffer : FixedBuffer ,
2424
25- pub fn init (buffer : []u8 ) StaticContext {
25+ pub fn init (buffer : []u8 ) FixedWriteContext {
2626 return .{ .buffer = .init (buffer ) };
2727 }
2828
2929 pub fn write (
30- ctx : * StaticContext ,
30+ ctx : * FixedWriteContext ,
3131 data : []const u8 ,
3232 ) usize {
3333 if (ctx .buffer .size + data .len > ctx .buffer .data .len ) {
@@ -39,24 +39,24 @@ pub const StaticContext = struct {
3939 return data .len ;
4040 }
4141
42- pub fn asSlice (self : * StaticContext ) []const u8 {
42+ pub fn asSlice (self : * FixedWriteContext ) []const u8 {
4343 return self .buffer .asSlice ();
4444 }
4545};
4646
47- pub const DynamicContext = struct {
48- buffer : DynamicBuffer ,
47+ pub const ResizableWriteContext = struct {
48+ buffer : ResizableBuffer ,
4949
50- pub fn init (allocator : Allocator ) DynamicContext {
51- return .{ .buffer = DynamicBuffer .init (allocator ) };
50+ pub fn init (allocator : Allocator ) ResizableWriteContext {
51+ return .{ .buffer = ResizableBuffer .init (allocator ) };
5252 }
5353
54- pub fn deinit (self : * DynamicContext ) void {
54+ pub fn deinit (self : * ResizableWriteContext ) void {
5555 self .buffer .deinit ();
5656 }
5757
5858 pub fn write (
59- ctx : * DynamicContext ,
59+ ctx : * ResizableWriteContext ,
6060 data : []const u8 ,
6161 ) usize {
6262 ctx .buffer .appendSlice (data ) catch {
@@ -67,7 +67,7 @@ pub const DynamicContext = struct {
6767 return data .len ;
6868 }
6969
70- pub fn asSlice (self : * DynamicContext ) []const u8 {
70+ pub fn asSlice (self : * ResizableWriteContext ) []const u8 {
7171 return self .buffer .items ;
7272 }
7373};
@@ -159,11 +159,11 @@ test "url encode" {
159159const CERT_MARKER_BEGIN = "-----BEGIN CERTIFICATE-----" ;
160160const CERT_MARKER_END = "\n -----END CERTIFICATE-----\n " ;
161161
162- pub fn allocCABundle (allocator : std.mem.Allocator ) ! DynamicBuffer {
162+ pub fn allocCABundle (allocator : std.mem.Allocator ) ! ResizableBuffer {
163163 var bundle : std.crypto.Certificate.Bundle = .{};
164164 defer bundle .deinit (allocator );
165165
166- var blob = DynamicBuffer .init (allocator );
166+ var blob = ResizableBuffer .init (allocator );
167167 try bundle .rescan (allocator );
168168 var iter = bundle .map .iterator ();
169169 while (iter .next ()) | entry | {
0 commit comments