Zig bindings for the notmuch C library
0

Configure Feed

Select the types of activity you want to include in your feed.

updates and build docs

Jeffrey C. Ollie (Mar 1, 2026, 2:35 PM -0600) dee18277 ff16889d

+37 -20
+16 -1
build.zig
··· 13 13 .target = target, 14 14 .optimize = optimize, 15 15 }); 16 - if (b.graph.environ_map.get("NOTMUCH_INCLUDE")) |path| notmuch_c.addIncludePath(.{ .cwd_relative = path }); 16 + if (b.graph.environ_map.get("NOTMUCH_INCLUDE")) |path| 17 + notmuch_c.addIncludePath(.{ .cwd_relative = path }); 17 18 18 19 const notmuch_zig = b.addModule("notmuch", .{ 19 20 .root_source_file = b.path("src/notmuch.zig"), ··· 32 33 33 34 const test_step = b.step("test", "Run unit tests"); 34 35 test_step.dependOn(&run_tests.step); 36 + 37 + const notmuch_lib = b.addLibrary(.{ 38 + .name = "notmuch", 39 + .root_module = notmuch_zig, 40 + }); 41 + 42 + const install_docs = b.addInstallDirectory(.{ 43 + .source_dir = notmuch_lib.getEmittedDocs(), 44 + .install_dir = .prefix, 45 + .install_subdir = "docs", 46 + }); 47 + 48 + const docs_step = b.step("docs", "Build the API docs"); 49 + docs_step.dependOn(&install_docs.step); 35 50 }
+21 -19
src/Database.zig
··· 12 12 const wrap = @import("error.zig").wrap; 13 13 const wrapMessage = @import("error.zig").wrapMessage; 14 14 15 - const CONFIG = @import("enums.zig").CONFIG; 16 - const DATABASE_MODE = @import("enums.zig").DATABASE_MODE; 17 - const DECRYPT = @import("enums.zig").DECRYPT; 18 - const QUERY_SYNTAX = @import("enums.zig").QUERY_SYNTAX; 15 + const enums = @import("enums.zig"); 16 + const CONFIG = enums.CONFIG; 17 + const DATABASE_MODE = enums.DATABASE_MODE; 18 + const DECRYPT = enums.DECRYPT; 19 + const QUERY_SYNTAX = enums.QUERY_SYNTAX; 19 20 20 21 const Message = @import("Message.zig"); 21 22 const Query = @import("Query.zig"); 22 23 23 24 database: *c.notmuch_database_t, 24 25 25 - pub fn open( 26 + pub const OpenOptions = struct { 27 + config_path: ?[:0]const u8, 26 28 database_path: ?[*:0]const u8, 27 - mode: DATABASE_MODE, 28 - config_path: ?[:0]const u8, 29 29 profile: ?[:0]const u8, 30 - ) Error!Database { 30 + }; 31 + 32 + pub fn open(mode: DATABASE_MODE, options: OpenOptions) Error!Database { 31 33 if (!c.LIBNOTMUCH_CHECK_VERSION(5, 6, 0)) { 32 - log.err("need newer notmuch", .{}); 33 34 return error.NotmuchVersion; 34 35 } 35 36 36 37 var error_message: [*c]u8 = null; 37 38 var database: ?*c.notmuch_database_t = null; 38 39 try wrapMessage(c.notmuch_database_open_with_config( 39 - database_path orelse null, 40 + options.database_path orelse null, 40 41 @intFromEnum(mode), 41 - config_path orelse null, 42 - profile orelse null, 42 + options.config_path orelse null, 43 + options.profile orelse null, 43 44 &database, 44 45 &error_message, 45 46 ), error_message); ··· 48 49 }; 49 50 } 50 51 51 - pub fn create( 52 + pub const CreateOptions = struct { 53 + config_path: ?[:0]const u8, 52 54 database_path: ?[*:0]const u8, 53 - config_path: ?[:0]const u8, 54 55 profile: ?[:0]const u8, 55 - ) Error!Database { 56 + }; 57 + 58 + pub fn create(options: CreateOptions) Error!Database { 56 59 if (!c.LIBNOTMUCH_CHECK_VERSION(5, 6, 0)) { 57 - log.err("need newer notmuch", .{}); 58 60 return error.NotmuchVersion; 59 61 } 60 62 ··· 62 64 var database: ?*c.notmuch_database_t = null; 63 65 try wrapMessage( 64 66 c.notmuch_database_create_with_config( 65 - database_path orelse null, 66 - config_path orelse null, 67 - profile orelse null, 67 + options.database_path orelse null, 68 + options.config_path orelse null, 69 + options.profile orelse null, 68 70 &database, 69 71 &error_message, 70 72 ),