mzteinit: update to latest Zig

This commit is contained in:
LordMZTE 2024-03-09 19:37:52 +01:00
parent 365c7b2ff1
commit acde8fb7be
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -8,14 +8,16 @@ const log = std.log.scoped(.server);
alloc: std.mem.Allocator, alloc: std.mem.Allocator,
env: *Mutex(std.process.EnvMap), env: *Mutex(std.process.EnvMap),
ss: std.net.StreamServer, ss: std.net.Server,
const Server = @This(); const Server = @This();
pub fn init(alloc: std.mem.Allocator, sockpath: []const u8, env: *Mutex(std.process.EnvMap)) !Server { pub fn init(alloc: std.mem.Allocator, sockpath: []const u8, env: *Mutex(std.process.EnvMap)) !Server {
var ss = std.net.StreamServer.init(.{}); return .{
try ss.listen(try std.net.Address.initUnix(sockpath)); .alloc = alloc,
return .{ .alloc = alloc, .ss = ss, .env = env }; .ss = try (try std.net.Address.initUnix(sockpath)).listen(.{}),
.env = env,
};
} }
pub fn run(self: *Server) !void { pub fn run(self: *Server) !void {
@ -26,7 +28,7 @@ pub fn run(self: *Server) !void {
} }
} }
pub fn handleConnection(self: *Server, con: std.net.StreamServer.Connection) !void { pub fn handleConnection(self: *Server, con: std.net.Server.Connection) !void {
defer con.stream.close(); defer con.stream.close();
while (true) { while (true) {
const msg = message.Serverbound.read(con.stream.reader(), self.alloc) catch |e| { const msg = message.Serverbound.read(con.stream.reader(), self.alloc) catch |e| {