Function libyml::yaml_emitter_flush
source · pub unsafe fn yaml_emitter_flush(emitter: *mut YamlEmitterT) -> Success
Expand description
Flushes the buffer of the emitter and writes the content to the output stream.
This function is called when the emitter needs to flush its buffer to the output stream. It first checks if the emitter is not null and if the write handler is not null. It also checks if the encoding of the emitter is not YamlAnyEncoding.
If the conditions are met, it updates the last and pointer of the buffer. If the encoding is YamlUtf8Encoding, it writes the content of the buffer to the output stream. If an error occurs during the write operation, it sets the error of the emitter and returns FAIL.
If the encoding is not YamlUtf8Encoding, it writes the content of the buffer to the raw buffer. It then writes the raw buffer to the output stream. If an error occurs during the write operation, it sets the error of the emitter and returns FAIL. If the write operation is successful, it returns OK.
§Arguments
emitter
- A pointer to the YamlEmitterT struct.
§Returns
Success
- An enum representing the success or failure of the operation.
§Safety
- The function is marked unsafe as it dereferences the pointer passed to it.
- The caller must ensure that the pointer is valid and points to a valid memory location.
- The caller must also ensure that the pointer is not null.
- The caller must ensure that the write handler is not null.
- The caller must ensure that the encoding is not YamlAnyEncoding.
- The caller must ensure that the write handler is a valid function pointer.