mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/sentry: custom transports
This commit is contained in:
10
pkg/sentry/envelope.zig
Normal file
10
pkg/sentry/envelope.zig
Normal file
@ -0,0 +1,10 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
/// sentry_envelope_t
|
||||
pub const Envelope = opaque {
|
||||
pub fn deinit(self: *Envelope) void {
|
||||
c.sentry_envelope_free(@ptrCast(self));
|
||||
}
|
||||
};
|
@ -1,6 +1,10 @@
|
||||
pub const c = @import("c.zig").c;
|
||||
|
||||
const transport = @import("transport.zig");
|
||||
|
||||
pub const Envelope = @import("envelope.zig").Envelope;
|
||||
pub const Level = @import("level.zig").Level;
|
||||
pub const Transport = transport.Transport;
|
||||
pub const Value = @import("value.zig").Value;
|
||||
pub const UUID = @import("uuid.zig").UUID;
|
||||
|
||||
|
26
pkg/sentry/transport.zig
Normal file
26
pkg/sentry/transport.zig
Normal file
@ -0,0 +1,26 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const c = @import("c.zig").c;
|
||||
const Envelope = @import("envelope.zig").Envelope;
|
||||
|
||||
/// sentry_transport_t
|
||||
pub const Transport = opaque {
|
||||
pub const SendFunc = *const fn (envelope: *Envelope, state: ?*anyopaque) callconv(.C) void;
|
||||
pub const FreeFunc = *const fn (state: ?*anyopaque) callconv(.C) void;
|
||||
|
||||
pub fn init(f: SendFunc) *Transport {
|
||||
return @ptrCast(c.sentry_transport_new(@ptrCast(f)).?);
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Transport) void {
|
||||
c.sentry_transport_free(@ptrCast(self));
|
||||
}
|
||||
|
||||
pub fn setState(self: *Transport, state: ?*anyopaque) void {
|
||||
c.sentry_transport_set_state(@ptrCast(self), state);
|
||||
}
|
||||
|
||||
pub fn setStateFreeFunc(self: *Transport, f: FreeFunc) void {
|
||||
c.sentry_transport_set_free_func(@ptrCast(self), f);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user