Class AsyncFile

    • Constructor Detail

      • AsyncFile

        public AsyncFile​(io.vertx.core.file.AsyncFile delegate)
      • AsyncFile

        public AsyncFile​(Object delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • pipeTo

        public io.smallrye.mutiny.Uni<Void> pipeTo​(WriteStream<Buffer> dst)
        Pipe this ReadStream to the WriteStream.

        Elements emitted by this stream will be written to the write stream until this stream ends or fails.

        Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        pipeTo in interface ReadStream<Buffer>
        Parameters:
        dst - the destination write stream
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • pipeToAndAwait

        public Void pipeToAndAwait​(WriteStream<Buffer> dst)
        Blocking variant of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        pipeToAndAwait in interface ReadStream<Buffer>
        Parameters:
        dst - the destination write stream
        Returns:
        the Void instance produced by the operation.
      • pipeToAndForget

        public void pipeToAndForget​(WriteStream<Buffer> dst)
        Variant of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream) but you don't need to compose it with other operations.

        Specified by:
        pipeToAndForget in interface ReadStream<Buffer>
        Parameters:
        dst - the destination write stream
      • write

        public io.smallrye.mutiny.Uni<Void> write​(Buffer data)
        Same as but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        write in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • writeAndAwait

        public Void writeAndAwait​(Buffer data)
        Blocking variant of io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        writeAndAwait in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the Void instance produced by the operation.
      • writeAndForget

        public void writeAndForget​(Buffer data)
        Variant of io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer) but you don't need to compose it with other operations.

        Specified by:
        writeAndForget in interface WriteStream<Buffer>
        Parameters:
        data -
      • end

        public io.smallrye.mutiny.Uni<Void> end()
        Same as WriteStream.end() but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<Buffer>
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait()
        Blocking variant of WriteStream.end().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<Buffer>
        Returns:
        the Void instance produced by the operation.
      • endAndForget

        public void endAndForget()
        Variant of WriteStream.end() that ignores the result of the operation.

        This method subscribes on the result of WriteStream.end(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from WriteStream.end() but you don't need to compose it with other operations.

        Specified by:
        endAndForget in interface WriteStream<Buffer>
      • end

        public io.smallrye.mutiny.Uni<Void> end​(Buffer data)
        Same as but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait​(Buffer data)
        Blocking variant of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the Void instance produced by the operation.
      • endAndForget

        public void endAndForget​(Buffer data)
        Variant of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer) but you don't need to compose it with other operations.

        Specified by:
        endAndForget in interface WriteStream<Buffer>
        Parameters:
        data -
      • pause

        public AsyncFile pause()
        Specified by:
        pause in interface ReadStream<Buffer>
        Returns:
        a reference to this, so the API can be used fluently
      • setWriteQueueMaxSize

        public AsyncFile setWriteQueueMaxSize​(int maxSize)
        Specified by:
        setWriteQueueMaxSize in interface WriteStream<Buffer>
        Parameters:
        maxSize - the max size of the write stream
        Returns:
        a reference to this, so the API can be used fluently
      • fetch

        public AsyncFile fetch​(long amount)
        Specified by:
        fetch in interface ReadStream<Buffer>
        Returns:
        a reference to this, so the API can be used fluently
      • close

        public io.smallrye.mutiny.Uni<Void> close()
        Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait()
        Blocking variant of close().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • closeAndForget

        public void closeAndForget()
        Variant of close() that ignores the result of the operation.

        This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

      • write

        public io.smallrye.mutiny.Uni<Void> write​(Buffer buffer,
                                                  long position)
        Write a Buffer to the file at position position in the file, asynchronously.

        If position lies outside of the current size of the file, the file will be enlarged to encompass it.

        When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur

        The handler will be called when the write is complete, or if an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        buffer - the buffer to write
        position - the position in the file to write it at
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • writeAndAwait

        public Void writeAndAwait​(Buffer buffer,
                                  long position)
        Blocking variant of write(io.vertx.mutiny.core.buffer.Buffer,long).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        buffer - the buffer to write
        position - the position in the file to write it at
        Returns:
        the Void instance produced by the operation.
      • read

        public io.smallrye.mutiny.Uni<Buffer> read​(Buffer buffer,
                                                   int offset,
                                                   long position,
                                                   int length)
        Reads length bytes of data from the file at position position in the file, asynchronously.

        The read data will be written into the specified Buffer buffer at position offset.

        If data is read past the end of the file then zero bytes will be read.

        When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.

        The handler will be called when the close is complete, or if an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        buffer - the buffer to read into
        offset - the offset into the buffer where the data will be read
        position - the position in the file where to start reading
        length - the number of bytes to read
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • readAndAwait

        public Buffer readAndAwait​(Buffer buffer,
                                   int offset,
                                   long position,
                                   int length)
        Blocking variant of read(io.vertx.mutiny.core.buffer.Buffer,int,long,int).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        buffer - the buffer to read into
        offset - the offset into the buffer where the data will be read
        position - the position in the file where to start reading
        length - the number of bytes to read
        Returns:
        the Buffer instance produced by the operation.
      • flush

        public io.smallrye.mutiny.Uni<Void> flush()
        Same as flush() but the handler will be called when the flush is complete or if an error occurs

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • flushAndAwait

        public Void flushAndAwait()
        Blocking variant of flush().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • flushAndForget

        public AsyncFile flushAndForget()
        Variant of flush() that ignores the result of the operation.

        This method subscribes on the result of flush(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from flush() but you don't need to compose it with other operations.

        Returns:
        the instance of AsyncFile to chain method calls.
      • setReadPos

        public AsyncFile setReadPos​(long readPos)
        Parameters:
        readPos - the position in the file
        Returns:
        a reference to this, so the API can be used fluently
      • setReadLength

        public AsyncFile setReadLength​(long readLength)
        Parameters:
        readLength - the bytes that will be read from the file
        Returns:
        a reference to this, so the API can be used fluently
      • getReadLength

        public long getReadLength()
        Returns:
        the number of bytes that will be read when using the file as a ReadStream
      • setWritePos

        public AsyncFile setWritePos​(long writePos)
        Parameters:
        writePos - the position in the file
        Returns:
        a reference to this, so the API can be used fluently
      • getWritePos

        public long getWritePos()
        Returns:
        the current write position the file is at
      • setReadBufferSize

        public AsyncFile setReadBufferSize​(int readBufferSize)
        Parameters:
        readBufferSize - the buffer size
        Returns:
        a reference to this, so the API can be used fluently
      • sizeBlocking

        public long sizeBlocking()
        Returns:
      • size

        public io.smallrye.mutiny.Uni<Long> size()
        Like size() but the handler will be called when the operation is complete or if an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • sizeAndAwait

        public Long sizeAndAwait()
        Blocking variant of size().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Long instance produced by the operation.
      • sizeAndForget

        public void sizeAndForget()
        Variant of size() that ignores the result of the operation.

        This method subscribes on the result of size(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from size() but you don't need to compose it with other operations.

      • toBlockingStream

        public Stream<Buffer> toBlockingStream()
      • newInstance

        public static AsyncFile newInstance​(io.vertx.core.file.AsyncFile arg)