Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor places connection management #718

Merged
merged 16 commits into from Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -48,11 +48,18 @@ internal interface LibPlacesFFI : Library {
// String will work but either force us to leak them, or cause us to corrupt the heap (when we
// free them).

/** Create a new places connection */
fun places_connection_new(
/** Create a new places api */
fun places_api_new(
db_path: String,
encryption_key: String?,
out_err: RustError.ByReference
): PlacesApiHandle

/** Create a new places connection */
fun places_connection_new(
handle: PlacesApiHandle,
conn_type: Int,
out_err: RustError.ByReference
): PlacesConnectionHandle

fun places_note_observation(
Expand Down Expand Up @@ -166,16 +173,24 @@ internal interface LibPlacesFFI : Library {
/** Destroy strings returned from libplaces_ffi calls. */
fun places_destroy_string(s: Pointer)

/** Destroy connection created using `places_connection_new` */
fun places_api_return_write_conn(apiHandle: PlacesApiHandle,
writeHandle: PlacesConnectionHandle,
err: RustError.ByReference)

/** Destroy connection created using `places_connection_new` */
fun places_connection_destroy(handle: PlacesConnectionHandle, out_err: RustError.ByReference)

/** Destroy api created using `places_api_new` */
fun places_api_destroy(handle: PlacesApiHandle, out_err: RustError.ByReference)

/** Destroy handle created using `places_new_interrupt_handle` */
fun places_interrupt_handle_destroy(obj: RawPlacesInterruptHandle)

fun places_destroy_bytebuffer(bb: RustBuffer.ByValue)
}

internal typealias PlacesConnectionHandle = Long;
internal typealias PlacesApiHandle = Long;

// This doesn't use a handle to avoid unnecessary locking and
// because the type is panic safe, sync, and send.
Expand Down