| 1 | // the public facade uses these guards for methods without a core operation. |
| 2 | module engine |
| 3 | |
| 4 | pub fn (mut handle Handle) validate_handle() ! { |
| 5 | handle.check()! |
| 6 | } |
| 7 | |
| 8 | pub fn (mut handle Handle) validate_handle_preserving_error() ! { |
| 9 | handle.require_live()! |
| 10 | } |
| 11 | |
| 12 | // sync.c's public getter returns the stored field even when computation fails. |
| 13 | // transaction preparation still uses the error-returning computation directly. |
| 14 | pub fn (mut handle Handle) package_download_size_value(mut pkg Package) !i64 { |
| 15 | handle.require_live()! |
| 16 | return handle.package_download_size(mut pkg) or { pkg.download_bytes } |
| 17 | } |
| 18 | |
| 19 | pub fn (mut handle Handle) set_error(kind Errno, detail string) IError { |
| 20 | return handle.fail(kind, detail) |
| 21 | } |
| 22 | |
| 23 | pub fn (mut db Database) validate_database() ! { |
| 24 | db.check()! |
| 25 | } |
| 26 | |
| 27 | // db.c metadata accessors do not use CHECK_HANDLE or clear pm_errno. |
| 28 | pub fn (mut db Database) validate_database_preserving_error() ! { |
| 29 | db.require_registered()! |
| 30 | } |
| 31 | |
| 32 | // Borrowed facade lists can be reused until cache membership or order changes. |
| 33 | pub fn (mut db Database) package_cache_revision() !u64 { |
| 34 | db.ensure_package_cache()! |
| 35 | return db.package_revision |
| 36 | } |
| 37 | |
| 38 | // Searching a successfully loaded cache leaves errno clear even on a miss. |
| 39 | pub fn (mut db Database) find_cached_package(name string) ?&Package { |
| 40 | db.ensure_package_cache() or { return none } |
| 41 | return db.by_name[c_string_prefix(name)] or { return none } |
| 42 | } |
| 43 | |