Skip to content

Commit f7c5e68

Browse files
committed
capi: update to chd 0.2
1 parent af1c507 commit f7c5e68

File tree

5 files changed

+37
-214
lines changed

5 files changed

+37
-214
lines changed

Cargo.lock

Lines changed: 12 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chd-rs-capi/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chd-capi"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
edition = "2021"
55
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
66
description = "libchdr-compatible C API for a Rust implementation of the CHD File Format"
@@ -21,7 +21,7 @@ chd_precache = []
2121
verify_block_crc = ["chd/verify_block_crc"]
2222

2323
[dependencies]
24-
chd = "0.1"
24+
chd = { version = "0.2", git = "https://github.com/SnowflakePowered/chd-rs" }
2525

2626
[build-dependencies]
2727
cbindgen = "0.24.3"

chd-rs-capi/chd.h

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -29,145 +29,6 @@
2929

3030
#define CHD_SHA1_BYTES 20
3131

32-
/**
33-
* Error types that may occur when reading a CHD file or hunk.
34-
*
35-
* This type tries to be ABI-compatible with [libchdr](https://github.com/rtissera/libchdr/blob/6eeb6abc4adc094d489c8ba8cafdcff9ff61251b/include/libchdr/chd.h#L258),
36-
* given sane defaults in the C compiler. See [repr(C) in the Rustonomicon](https://doc.rust-lang.org/nomicon/other-reprs.html#reprc) for more details.
37-
*/
38-
typedef enum chd_error {
39-
/**
40-
* No error.
41-
* This is only used by the C API bindings.
42-
*/
43-
CHDERR_NONE,
44-
/**
45-
* No drive interface.
46-
* This is only for C-compatibility purposes and is otherwise unused.
47-
*/
48-
CHDERR_NO_INTERFACE,
49-
/**
50-
* Unable to allocate the required size of buffer.
51-
*/
52-
CHDERR_OUT_OF_MEMORY,
53-
/**
54-
* The file is not a valid CHD file.
55-
*/
56-
CHDERR_INVALID_FILE,
57-
/**
58-
* An invalid parameter was provided.
59-
*/
60-
CHDERR_INVALID_PARAMETER,
61-
/**
62-
* The data is invalid.
63-
*/
64-
CHDERR_INVALID_DATA,
65-
/**
66-
* The file was not found.
67-
*/
68-
CHDERR_FILE_NOT_FOUND,
69-
/**
70-
* This CHD requires a parent CHD that was not provided.
71-
*/
72-
CHDERR_REQUIRES_PARENT,
73-
/**
74-
* The provided file is not writable.
75-
* Since chd-rs does not implement CHD creation, this is unused.
76-
*/
77-
CHDERR_FILE_NOT_WRITEABLE,
78-
/**
79-
* An error occurred when reading this CHD file.
80-
*/
81-
CHDERR_READ_ERROR,
82-
/**
83-
* An error occurred when writing this CHD file.
84-
* Since chd-rs does not implement CHD creation, this is unused.
85-
*/
86-
CHDERR_WRITE_ERROR,
87-
/**
88-
* An error occurred when initializing a codec.
89-
*/
90-
CHDERR_CODEC_ERROR,
91-
/**
92-
* The provided parent CHD is invalid.
93-
*/
94-
CHDERR_INVALID_PARENT,
95-
/**
96-
* The request hunk is out of range for this CHD file.
97-
*/
98-
CHDERR_HUNK_OUT_OF_RANGE,
99-
/**
100-
* An error occurred when decompressing a hunk.
101-
*/
102-
CHDERR_DECOMPRESSION_ERROR,
103-
/**
104-
* An error occurred when compressing a hunk.
105-
* Since chd-rs does not implement CHD creation, this is unused.
106-
*/
107-
CHDERR_COMPRESSION_ERROR,
108-
/**
109-
* Could not create the file.
110-
* Since chd-rs does not implement CHD creation, this is unused.
111-
*/
112-
CHDERR_CANT_CREATE_FILE,
113-
/**
114-
* Could not verify the CHD.
115-
* This is only for C-compatibility purposes and is otherwise unused.
116-
*/
117-
CHDERR_CANT_VERIFY,
118-
/**
119-
* The requested operation is not supported.
120-
* This is only for C-compatibility purposes and is otherwise unused.
121-
*/
122-
CHDERR_NOT_SUPPORTED,
123-
/**
124-
* The requested metadata was not found.
125-
* This is only used by the C API bindings.
126-
*/
127-
CHDERR_METADATA_NOT_FOUND,
128-
/**
129-
* The metadata has an invalid size.
130-
* This is only for C-compatibility purposes and is otherwise unused.
131-
*/
132-
CHDERR_INVALID_METADATA_SIZE,
133-
/**
134-
* The CHD version of the provided file is not supported by this library.
135-
*/
136-
CHDERR_UNSUPPORTED_VERSION,
137-
/**
138-
* Unable to verify the CHD completely.
139-
* This is only for C-compatibility purposes and is otherwise unused.
140-
*/
141-
CHDERR_VERIFY_INCOMPLETE,
142-
/**
143-
* The requested metadata is invalid.
144-
*/
145-
CHDERR_INVALID_METADATA,
146-
/**
147-
* The internal state of the decoder/encoder is invalid.
148-
* This is only for C-compatibility purposes and is otherwise unused.
149-
*/
150-
CHDERR_INVALID_STATE,
151-
/**
152-
* An operation is already pending.
153-
* This is only for C-compatibility purposes and is otherwise unused.
154-
*/
155-
CHDERR_OPERATION_PENDING,
156-
/**
157-
* No async operations are allowed.
158-
* This is only for C-compatibility purposes and is otherwise unused.
159-
*/
160-
CHDERR_NO_ASYNC_OPERATION,
161-
/**
162-
* Decompressing the CHD requires a codec that is not supported.
163-
*/
164-
CHDERR_UNSUPPORTED_FORMAT,
165-
/**
166-
* Unknown error.
167-
*/
168-
CHDERR_UNKNOWN,
169-
} chd_error;
170-
17132
/**
17233
* An opaque type for an opened CHD file.
17334
*/

chd-rs-capi/src/header.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::chd_file;
2-
use chd::header::{ChdHeader, HeaderV1, HeaderV3, HeaderV4, HeaderV5};
3-
use chd::map::ChdMap;
2+
use chd::header::{Header, HeaderV1, HeaderV3, HeaderV4, HeaderV5};
3+
use chd::map::Map;
44
use std::mem;
55

66
pub const CHD_MD5_BYTES: usize = 16;
@@ -128,11 +128,11 @@ impl From<&HeaderV4> for chd_header {
128128

129129
pub(crate) fn get_v5_header(chd: &chd_file) -> chd_header {
130130
let header: HeaderV5 = match chd.header() {
131-
ChdHeader::V5Header(h) => h.clone(),
131+
Header::V5Header(h) => h.clone(),
132132
_ => unreachable!(),
133133
};
134134
let mut map_data: Vec<u8> = match chd.map() {
135-
ChdMap::V5(map) => map.into(),
135+
Map::V5(map) => map.into(),
136136
_ => unreachable!(),
137137
};
138138
let version = header.version;

0 commit comments

Comments
 (0)