Skip to content

Commit f680ea2

Browse files
committed
make api public
1 parent 2a95617 commit f680ea2

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

Diff for: Sources/Libsql/Libsql.swift

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
import CLibsql
22
import Foundation
33

4-
enum Value {
4+
public enum Value {
55
case integer(Int64)
66
case text(String)
77
case blob(Data)
88
case real(Double)
99
case null
1010
}
1111

12-
protocol ValueRepresentable {
12+
public protocol ValueRepresentable {
1313
func toValue() -> Value
1414
}
1515

1616
extension Value: ValueRepresentable {
17-
func toValue() -> Value { self }
17+
public func toValue() -> Value { self }
1818
}
1919

2020
extension Int: ValueRepresentable {
21-
func toValue() -> Value { .integer(Int64(self)) }
21+
public func toValue() -> Value { .integer(Int64(self)) }
2222
}
2323

2424
extension Int64: ValueRepresentable {
25-
func toValue() -> Value { .integer(self) }
25+
public func toValue() -> Value { .integer(self) }
2626
}
2727

2828
extension String: ValueRepresentable {
29-
func toValue() -> Value { .text(self) }
29+
public func toValue() -> Value { .text(self) }
3030
}
3131

3232
extension Data: ValueRepresentable {
33-
func toValue() -> Value { .blob(self) }
33+
public func toValue() -> Value { .blob(self) }
3434
}
3535

3636
extension Double: ValueRepresentable {
37-
func toValue() -> Value { .real(self) }
37+
public func toValue() -> Value { .real(self) }
3838
}
3939

4040
extension String? {
@@ -52,7 +52,7 @@ enum LibsqlError: Error {
5252
case unexpectedType
5353
}
5454

55-
class Row {
55+
public class Row {
5656
var inner: libsql_row_t
5757

5858
fileprivate init?(fromPtr inner: libsql_row_t?) {
@@ -63,7 +63,7 @@ class Row {
6363
self.inner = inner
6464
}
6565

66-
func getData(_ index: Int32) throws -> Data {
66+
public func getData(_ index: Int32) throws -> Data {
6767
var slice: blob = blob()
6868

6969
var err: UnsafePointer<CChar>?
@@ -77,7 +77,7 @@ class Row {
7777
return Data(bytes: slice.ptr, count: Int(slice.len))
7878
}
7979

80-
func getDouble(_ index: Int32) throws -> Double {
80+
public func getDouble(_ index: Int32) throws -> Double {
8181
var double: Double = 0
8282

8383
var err: UnsafePointer<CChar>?
@@ -89,7 +89,7 @@ class Row {
8989
return double
9090
}
9191

92-
func getString(_ index: Int32) throws -> String {
92+
public func getString(_ index: Int32) throws -> String {
9393
var string: UnsafePointer<CChar>? = nil
9494

9595
var err: UnsafePointer<CChar>?
@@ -103,7 +103,7 @@ class Row {
103103
return String(cString: string!)
104104
}
105105

106-
func getInt(_ index: Int32) throws -> Int {
106+
public func getInt(_ index: Int32) throws -> Int {
107107
var integer: Int64 = 0
108108

109109
var err: UnsafePointer<CChar>?
@@ -116,7 +116,7 @@ class Row {
116116
}
117117
}
118118

119-
class Rows: Sequence, IteratorProtocol {
119+
public class Rows: Sequence, IteratorProtocol {
120120
var inner: libsql_rows_t
121121

122122
fileprivate init(fromPtr inner: libsql_rows_t) {
@@ -127,7 +127,7 @@ class Rows: Sequence, IteratorProtocol {
127127
libsql_free_rows(self.inner)
128128
}
129129

130-
func next() -> Row? {
130+
public func next() -> Row? {
131131
var row: libsql_row_t?
132132

133133
var err: UnsafePointer<CChar>?
@@ -140,7 +140,7 @@ class Rows: Sequence, IteratorProtocol {
140140
}
141141
}
142142

143-
class Statement {
143+
public class Statement {
144144
var inner: libsql_stmt_t
145145

146146
deinit {
@@ -151,25 +151,25 @@ class Statement {
151151
self.inner = inner
152152
}
153153

154-
func execute() throws {
154+
public func execute() throws {
155155
var err: UnsafePointer<CChar>? = nil
156156
if libsql_execute_stmt(self.inner, &err) != 0 {
157157
defer { libsql_free_string(err) }
158158
throw LibsqlError.runtimeError(String(cString: err!))
159159
}
160160
}
161161

162-
func execute(_ params: [ValueRepresentable]) throws {
162+
public func execute(_ params: [ValueRepresentable]) throws {
163163
try self.bind(params)
164164
return try self.execute()
165165
}
166166

167-
func execute(_ params: ValueRepresentable...) throws {
167+
public func execute(_ params: ValueRepresentable...) throws {
168168
try self.bind(params)
169169
return try self.execute()
170170
}
171171

172-
func query() throws -> Rows {
172+
public func query() throws -> Rows {
173173
var rows: libsql_rows_t? = nil
174174

175175
var err: UnsafePointer<CChar>? = nil
@@ -181,21 +181,21 @@ class Statement {
181181
return Rows(fromPtr: rows!)
182182
}
183183

184-
func query(_ params: [ValueRepresentable]) throws -> Rows {
184+
public func query(_ params: [ValueRepresentable]) throws -> Rows {
185185
try self.bind(params)
186186
return try self.query()
187187
}
188188

189-
func query(_ params: ValueRepresentable...) throws -> Rows {
189+
public func query(_ params: ValueRepresentable...) throws -> Rows {
190190
try self.bind(params)
191191
return try self.query()
192192
}
193193

194-
func bind(_ params: ValueRepresentable...) throws {
194+
public func bind(_ params: ValueRepresentable...) throws {
195195
return try self.bind(params)
196196
}
197197

198-
func bind(_ params: [ValueRepresentable]) throws {
198+
public func bind(_ params: [ValueRepresentable]) throws {
199199
for (i, v) in params.enumerated() {
200200
let i = Int32(i + 1)
201201

@@ -242,7 +242,7 @@ class Statement {
242242
}
243243
}
244244

245-
class Connection {
245+
public class Connection {
246246
var inner: libsql_connection_t
247247

248248
deinit {
@@ -253,7 +253,7 @@ class Connection {
253253
self.inner = inner
254254
}
255255

256-
func query(_ sql: String) throws -> Rows {
256+
public func query(_ sql: String) throws -> Rows {
257257
var rows: libsql_rows_t? = nil
258258
try sql.withCString { sql in
259259
var err: UnsafePointer<CChar>? = nil
@@ -266,16 +266,16 @@ class Connection {
266266
return Rows(fromPtr: rows!)
267267
}
268268

269-
func query(_ sql: String, _ params: [ValueRepresentable]) throws -> Rows {
269+
public func query(_ sql: String, _ params: [ValueRepresentable]) throws -> Rows {
270270
let stmt = try self.prepare(sql)
271271
return try stmt.query(params)
272272
}
273273

274-
func query(_ sql: String, _ params: ValueRepresentable...) throws -> Rows {
274+
public func query(_ sql: String, _ params: ValueRepresentable...) throws -> Rows {
275275
return try self.query(sql, params as [ValueRepresentable])
276276
}
277277

278-
func execute(_ sql: String) throws {
278+
public func execute(_ sql: String) throws {
279279
try sql.withCString { sql in
280280
var err: UnsafePointer<CChar>? = nil
281281
if libsql_execute(self.inner, sql, &err) != 0 {
@@ -285,16 +285,16 @@ class Connection {
285285
}
286286
}
287287

288-
func execute(_ sql: String, _ params: [ValueRepresentable]) throws {
288+
public func execute(_ sql: String, _ params: [ValueRepresentable]) throws {
289289
let stmt = try self.prepare(sql)
290290
return try stmt.execute(params)
291291
}
292292

293-
func execute(_ sql: String, _ params: ValueRepresentable...) throws {
293+
public func execute(_ sql: String, _ params: ValueRepresentable...) throws {
294294
return try self.execute(sql, params as [ValueRepresentable])
295295
}
296296

297-
func prepare(_ sql: String) throws -> Statement {
297+
public func prepare(_ sql: String) throws -> Statement {
298298
var stmt: libsql_stmt_t? = nil
299299

300300
try sql.withCString { sql in
@@ -309,22 +309,22 @@ class Connection {
309309
}
310310
}
311311

312-
class Database {
312+
public class Database {
313313
var inner: libsql_database_t
314314

315315
deinit {
316316
libsql_close(self.inner)
317317
}
318318

319-
func sync() throws {
319+
public func sync() throws {
320320
var err: UnsafePointer<CChar>? = nil
321321
if libsql_sync(self.inner, &err) != 0 {
322322
defer { libsql_free_string(err) }
323323
throw LibsqlError.runtimeError(String(cString: err!))
324324
}
325325
}
326326

327-
func connect() throws -> Connection {
327+
public func connect() throws -> Connection {
328328
var conn: libsql_connection_t? = nil
329329

330330
var err: UnsafePointer<CChar>? = nil
@@ -336,7 +336,7 @@ class Database {
336336
return Connection(fromPtr: conn!)
337337
}
338338

339-
init(_ path: String) throws {
339+
public init(_ path: String) throws {
340340
var db: libsql_database_t? = nil
341341

342342
try path.withCString { path in
@@ -350,7 +350,7 @@ class Database {
350350
self.inner = db!
351351
}
352352

353-
init(url: String, authToken: String, withWebpki: Bool = false) throws {
353+
public init(url: String, authToken: String, withWebpki: Bool = false) throws {
354354
var db: libsql_database_t? = nil
355355

356356
try url.withCString { url in
@@ -374,7 +374,7 @@ class Database {
374374
self.inner = db!
375375
}
376376

377-
init(
377+
public init(
378378
path: String,
379379
url: String,
380380
authToken: String,

0 commit comments

Comments
 (0)