// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
//     public static class ByValue extends Error implements Structure.ByValue {
//         public void checkError() {
//             if (error != null) {
//                 BoltNative.Error_Free(this);
//                 throw new BoltException(error);
//             }
//         }
//     }
// 
//     public String error;
// 
//     @Override
//     protected List<String> getFieldOrder() {
//         return Collections.singletonList("error");
//     }
// }


import com.protonail.bolt.jna.impl.*;
import com.protonail.bolt.jna.impl.Error;
package com.protonail.bolt.jna;


public class BoltBucket implements AutoCloseable {
    long objectId;

    BoltBucket(long objectId) {
        this.objectId = objectId;
    }

    @Override
    public void close() {
        BoltNative.BoltDBBucket_Free(objectId);
    }

    public byte[] get(byte[] key) {
        try(Value.ByValue value = BoltNative.BoltDBBucket_Get(objectId, key, key.length)) {
            return value.hasValue() ? value.getValue() : null;
        }
    }

    public void put(byte[] key, byte[] value) {
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
//     public static class ByValue extends Error implements Structure.ByValue {
//         public void checkError() {
//             if (error != null) {
//                 BoltNative.Error_Free(this);
//                 throw new BoltException(error);
//             }
//         }
//     }
// 
//     public String error;
// 
//     @Override
//     protected List<String> getFieldOrder() {
//         return Collections.singletonList("error");
//     }
// }


// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltBucket.java
import com.protonail.bolt.jna.impl.*;
import com.protonail.bolt.jna.impl.Error;

package com.protonail.bolt.jna;


public class BoltBucket implements AutoCloseable {
    long objectId;

    BoltBucket(long objectId) {
        this.objectId = objectId;
    }

    @Override
    public void close() {
        BoltNative.BoltDBBucket_Free(objectId);
    }

    public byte[] get(byte[] key) {
        try(Value.ByValue value = BoltNative.BoltDBBucket_Get(objectId, key, key.length)) {
            return value.hasValue() ? value.getValue() : null;
        }
    }

    public void put(byte[] key, byte[] value) {
        Error.ByValue error = BoltNative.BoltDBBucket_Put(objectId, key, key.length, value, value.length);