Skip to content

Commit 4b3b52e

Browse files
committed
refactor: SpringRow -> SpringSinkRow
1 parent f998afd commit 4b3b52e

3 files changed

Lines changed: 35 additions & 35 deletions

File tree

springql.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef void *SpringPipeline;
5252
/**
5353
* Row object from an in memory queue.
5454
*/
55-
typedef void *SpringRow;
55+
typedef void *SpringSinkRow;
5656

5757
/**
5858
* Returns default configuration.
@@ -146,7 +146,7 @@ enum SpringErrno spring_command(const SpringPipeline *pipeline, const char *sql)
146146
*
147147
* - `Unavailable`: queue named `queue` does not exist.
148148
*/
149-
SpringRow *spring_pop(const SpringPipeline *pipeline, const char *queue);
149+
SpringSinkRow *spring_pop(const SpringPipeline *pipeline, const char *queue);
150150

151151
/**
152152
* Pop a row from an in memory queue. This is a non-blocking function.
@@ -160,9 +160,9 @@ SpringRow *spring_pop(const SpringPipeline *pipeline, const char *queue);
160160
*
161161
* - `Unavailable`: queue named `queue` does not exist.
162162
*/
163-
SpringRow *spring_pop_non_blocking(const SpringPipeline *pipeline,
164-
const char *queue,
165-
bool *is_err);
163+
SpringSinkRow *spring_pop_non_blocking(const SpringPipeline *pipeline,
164+
const char *queue,
165+
bool *is_err);
166166

167167
/**
168168
* Frees heap occupied by a `SpringRow`.
@@ -172,7 +172,7 @@ SpringRow *spring_pop_non_blocking(const SpringPipeline *pipeline,
172172
* - `Ok`: on success.
173173
* - `CNull`: `pipeline` is a NULL pointer.
174174
*/
175-
enum SpringErrno spring_row_close(SpringRow *row);
175+
enum SpringErrno spring_row_close(SpringSinkRow *row);
176176

177177
/**
178178
* Get a 2-byte integer column.
@@ -191,7 +191,7 @@ enum SpringErrno spring_row_close(SpringRow *row);
191191
* - `i_col` is out of range.
192192
* - `CNull`: Column value is NULL.
193193
*/
194-
enum SpringErrno spring_column_short(const SpringRow *row, uint16_t i_col, short *out);
194+
enum SpringErrno spring_column_short(const SpringSinkRow *row, uint16_t i_col, short *out);
195195

196196
/**
197197
* Get a 4-byte integer column.
@@ -210,7 +210,7 @@ enum SpringErrno spring_column_short(const SpringRow *row, uint16_t i_col, short
210210
* - `i_col` is out of range.
211211
* - `CNull`: Column value is NULL.
212212
*/
213-
enum SpringErrno spring_column_int(const SpringRow *row, uint16_t i_col, int *out);
213+
enum SpringErrno spring_column_int(const SpringSinkRow *row, uint16_t i_col, int *out);
214214

215215
/**
216216
* Get an 8-byte integer column.
@@ -229,7 +229,7 @@ enum SpringErrno spring_column_int(const SpringRow *row, uint16_t i_col, int *ou
229229
* - `i_col` is out of range.
230230
* - `CNull`: Column value is NULL.
231231
*/
232-
enum SpringErrno spring_column_long(const SpringRow *row, uint16_t i_col, long *out);
232+
enum SpringErrno spring_column_long(const SpringSinkRow *row, uint16_t i_col, long *out);
233233

234234
/**
235235
* Get a 4-byte unsigned integer column.
@@ -248,7 +248,7 @@ enum SpringErrno spring_column_long(const SpringRow *row, uint16_t i_col, long *
248248
* - `i_col` is out of range.
249249
* - `CNull`: Column value is NULL.
250250
*/
251-
enum SpringErrno spring_column_unsigned_int(const SpringRow *row,
251+
enum SpringErrno spring_column_unsigned_int(const SpringSinkRow *row,
252252
uint16_t i_col,
253253
unsigned int *out);
254254

@@ -270,7 +270,7 @@ enum SpringErrno spring_column_unsigned_int(const SpringRow *row,
270270
* - `i_col` is out of range.
271271
* - `CNull`: Column value is NULL.
272272
*/
273-
int spring_column_text(const SpringRow *row, uint16_t i_col, char *out, int out_len);
273+
int spring_column_text(const SpringSinkRow *row, uint16_t i_col, char *out, int out_len);
274274

275275
/**
276276
* Get a BLOB column.
@@ -290,7 +290,7 @@ int spring_column_text(const SpringRow *row, uint16_t i_col, char *out, int out_
290290
* - `i_col` is out of range.
291291
* - `CNull`: Column value is NULL.
292292
*/
293-
int spring_column_blob(const SpringRow *row, uint16_t i_col, void *out, int out_len);
293+
int spring_column_blob(const SpringSinkRow *row, uint16_t i_col, void *out, int out_len);
294294

295295
/**
296296
* Get a bool column.
@@ -309,7 +309,7 @@ int spring_column_blob(const SpringRow *row, uint16_t i_col, void *out, int out_
309309
* - `i_col` is out of range.
310310
* - `CNull`: Column value is NULL.
311311
*/
312-
enum SpringErrno spring_column_bool(const SpringRow *row, uint16_t i_col, bool *out);
312+
enum SpringErrno spring_column_bool(const SpringSinkRow *row, uint16_t i_col, bool *out);
313313

314314
/**
315315
* Get a 4-byte floating point column.
@@ -328,7 +328,7 @@ enum SpringErrno spring_column_bool(const SpringRow *row, uint16_t i_col, bool *
328328
* - `i_col` is out of range.
329329
* - `CNull`: Column value is NULL.
330330
*/
331-
enum SpringErrno spring_column_float(const SpringRow *row, uint16_t i_col, float *out);
331+
enum SpringErrno spring_column_float(const SpringSinkRow *row, uint16_t i_col, float *out);
332332

333333
/**
334334
* Write the most recent error number into `errno` and message into a caller-provided buffer as a UTF-8

src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod spring_config;
99
pub mod spring_errno;
1010
pub mod spring_last_err;
1111
mod spring_pipeline;
12-
mod spring_row;
12+
mod spring_sink_row;
1313

1414
use std::{
1515
ffi::{c_void, CStr},
@@ -24,7 +24,7 @@ use crate::{
2424
spring_errno::SpringErrno,
2525
spring_last_err::{update_last_error, LastError},
2626
spring_pipeline::SpringPipeline,
27-
spring_row::SpringRow,
27+
spring_sink_row::SpringSinkRow,
2828
};
2929
use ::springql::{error::SpringError, SpringPipeline as Pipeline};
3030

@@ -163,13 +163,13 @@ pub unsafe extern "C" fn spring_command(
163163
pub unsafe extern "C" fn spring_pop(
164164
pipeline: *const SpringPipeline,
165165
queue: *const c_char,
166-
) -> *mut SpringRow {
166+
) -> *mut SpringSinkRow {
167167
let pipeline = (*pipeline).as_pipeline();
168168
let queue = CStr::from_ptr(queue).to_string_lossy().into_owned();
169169
let result = with_catch(|| pipeline.pop(&queue));
170170
match result {
171171
Ok(row) => {
172-
let row = SpringRow::new(row);
172+
let row = SpringSinkRow::new(row);
173173
row.into_ptr()
174174
}
175175
Err(_) => ptr::null_mut(),
@@ -191,13 +191,13 @@ pub unsafe extern "C" fn spring_pop_non_blocking(
191191
pipeline: *const SpringPipeline,
192192
queue: *const c_char,
193193
is_err: *mut bool,
194-
) -> *mut SpringRow {
194+
) -> *mut SpringSinkRow {
195195
let pipeline = (*pipeline).as_pipeline();
196196
let queue = CStr::from_ptr(queue).to_string_lossy().into_owned();
197197
let result = with_catch(|| pipeline.pop_non_blocking(&queue));
198198
match result {
199199
Ok(Some(row)) => {
200-
let ptr = SpringRow::new(row);
200+
let ptr = SpringSinkRow::new(row);
201201
*is_err = false;
202202
ptr.into_ptr()
203203
}
@@ -219,11 +219,11 @@ pub unsafe extern "C" fn spring_pop_non_blocking(
219219
/// - `Ok`: on success.
220220
/// - `CNull`: `pipeline` is a NULL pointer.
221221
#[no_mangle]
222-
pub extern "C" fn spring_row_close(row: *mut SpringRow) -> SpringErrno {
222+
pub extern "C" fn spring_row_close(row: *mut SpringSinkRow) -> SpringErrno {
223223
if row.is_null() {
224224
SpringErrno::CNull
225225
} else {
226-
SpringRow::drop(row);
226+
SpringSinkRow::drop(row);
227227
SpringErrno::Ok
228228
}
229229
}
@@ -245,7 +245,7 @@ pub extern "C" fn spring_row_close(row: *mut SpringRow) -> SpringErrno {
245245
/// - `CNull`: Column value is NULL.
246246
#[no_mangle]
247247
pub unsafe extern "C" fn spring_column_short(
248-
row: *const SpringRow,
248+
row: *const SpringSinkRow,
249249
i_col: u16,
250250
out: *mut c_short,
251251
) -> SpringErrno {
@@ -278,7 +278,7 @@ pub unsafe extern "C" fn spring_column_short(
278278
/// - `CNull`: Column value is NULL.
279279
#[no_mangle]
280280
pub unsafe extern "C" fn spring_column_int(
281-
row: *const SpringRow,
281+
row: *const SpringSinkRow,
282282
i_col: u16,
283283
out: *mut c_int,
284284
) -> SpringErrno {
@@ -311,7 +311,7 @@ pub unsafe extern "C" fn spring_column_int(
311311
/// - `CNull`: Column value is NULL.
312312
#[no_mangle]
313313
pub unsafe extern "C" fn spring_column_long(
314-
row: *const SpringRow,
314+
row: *const SpringSinkRow,
315315
i_col: u16,
316316
out: *mut c_long,
317317
) -> SpringErrno {
@@ -344,7 +344,7 @@ pub unsafe extern "C" fn spring_column_long(
344344
/// - `CNull`: Column value is NULL.
345345
#[no_mangle]
346346
pub unsafe extern "C" fn spring_column_unsigned_int(
347-
row: *const SpringRow,
347+
row: *const SpringSinkRow,
348348
i_col: u16,
349349
out: *mut c_uint,
350350
) -> SpringErrno {
@@ -378,7 +378,7 @@ pub unsafe extern "C" fn spring_column_unsigned_int(
378378
/// - `CNull`: Column value is NULL.
379379
#[no_mangle]
380380
pub unsafe extern "C" fn spring_column_text(
381-
row: *const SpringRow,
381+
row: *const SpringSinkRow,
382382
i_col: u16,
383383
out: *mut c_char,
384384
out_len: c_int,
@@ -414,7 +414,7 @@ pub unsafe extern "C" fn spring_column_text(
414414
/// - `CNull`: Column value is NULL.
415415
#[no_mangle]
416416
pub unsafe extern "C" fn spring_column_blob(
417-
row: *const SpringRow,
417+
row: *const SpringSinkRow,
418418
i_col: u16,
419419
out: *mut c_void,
420420
out_len: c_int,
@@ -449,7 +449,7 @@ pub unsafe extern "C" fn spring_column_blob(
449449
/// - `CNull`: Column value is NULL.
450450
#[no_mangle]
451451
pub unsafe extern "C" fn spring_column_bool(
452-
row: *const SpringRow,
452+
row: *const SpringSinkRow,
453453
i_col: u16,
454454
out: *mut bool,
455455
) -> SpringErrno {
@@ -482,7 +482,7 @@ pub unsafe extern "C" fn spring_column_bool(
482482
/// - `CNull`: Column value is NULL.
483483
#[no_mangle]
484484
pub unsafe extern "C" fn spring_column_float(
485-
row: *const SpringRow,
485+
row: *const SpringSinkRow,
486486
i_col: u16,
487487
out: *mut c_float,
488488
) -> SpringErrno {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ use std::{ffi::c_void, mem};
66
/// Row object from an in memory queue.
77
#[non_exhaustive]
88
#[repr(transparent)]
9-
pub struct SpringRow(*mut c_void);
9+
pub struct SpringSinkRow(*mut c_void);
1010

11-
impl SpringRow {
11+
impl SpringSinkRow {
1212
pub fn new(sink_row: SinkRow) -> Self {
13-
SpringRow(unsafe { mem::transmute(Box::new(sink_row)) })
13+
SpringSinkRow(unsafe { mem::transmute(Box::new(sink_row)) })
1414
}
1515

1616
pub fn as_row(&self) -> &SinkRow {
1717
unsafe { &*(self.0 as *const SinkRow) }
1818
}
1919

20-
pub fn drop(ptr: *mut SpringRow) {
20+
pub fn drop(ptr: *mut SpringSinkRow) {
2121
let outer = unsafe { Box::from_raw(ptr) };
2222
let inner = unsafe { Box::from_raw(outer.0) };
2323
drop(inner);
2424
drop(outer);
2525
}
2626

27-
pub fn into_ptr(self) -> *mut SpringRow {
27+
pub fn into_ptr(self) -> *mut SpringSinkRow {
2828
Box::into_raw(Box::new(self))
2929
}
3030
}

0 commit comments

Comments
 (0)