- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
WriteFunc is the type of function which is called when a backend needs to
write data to an output stream. It is passed the closure which was specified
by the user at the time the write function was registered, the data to write
and the length of the data in bytes. The write function should throw
IOException if all the data was not successfully written.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault MemorySegmenttoCallback(Arena arena) Generates an upcall stub, a C function pointer that will callupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int).default intupcall(MemorySegment closure, MemorySegment data, int length) The callback that is executed by native code.voidwrite(byte[] data) The function to implement as callback in a write operation to an output stream.
-
Method Details
-
write
The function to implement as callback in a write operation to an output stream.- Parameters:
data- the data to write to the output stream- Throws:
IOException- to be thrown when an error occurs during the write operation- Since:
- 1.0
-
upcall
The callback that is executed by native code. This method marshals the parameters and callswrite(byte[]).- Parameters:
closure- ignoreddata- the buffer from which to read the datalength- the amount of data to write- Returns:
Status.SUCCESSon success, orStatus.WRITE_ERRORif an IOException occured.- 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
-