- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ReadFunc is the type of function which is called when a backend needs to read
data from an input stream. It is passed the closure which was specified by
the user at the time the read function was registered, the buffer to read the
data into and the length of the data in bytes. The read function should throw
IOException
if all the data was not successfully read.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
read
(int length) The function to implement as callback in a read operation from an input stream.default MemorySegment
toCallback
(Arena arena) Generates an upcall stub, a C function pointer that will callupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
.default int
upcall
(MemorySegment closure, MemorySegment data, int length) The callback that is executed by native code.
-
Method Details
-
read
The function to implement as callback in a read operation from an input stream.- Parameters:
length
- the amount of data to read- Returns:
- data the data read from the input stream
- Throws:
IOException
- to be thrown when an error occurs during the read operation- Since:
- 1.0
-
upcall
The callback that is executed by native code. This method marshals the parameters and callsread(int)
.- Parameters:
closure
- ignoreddata
- the buffer into which to read the datalength
- the amount of data to read- Returns:
Status.SUCCESS
on success, orStatus.READ_ERROR
if an IOException occured or 0 bytes (or null) was returned fromread()
.- Since:
- 1.0
-
toCallback
Generates an upcall stub, a C function pointer that will callupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
.- Parameters:
arena
- the arena in which the upcall stub will be allocated- Returns:
- the function pointer of the upcall stub
- Since:
- 1.0
-