/** * Convert to a {@link ByteBuffer} inbound {@link Flux} * * @return a {@link ByteBuffer} inbound {@link Flux} */ public final Flux<ByteBuffer> asByteBuffer() { return handle((bb, sink) -> { try { sink.next(bb.nioBuffer()); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@literal byte[]} inbound {@link Flux} * * @return a {@literal byte[]} inbound {@link Flux} */ public final Flux<byte[]> asByteArray() { return handle((bb, sink) -> { try { byte[] bytes = new byte[bb.readableBytes()]; bb.readBytes(bytes); sink.next(bytes); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@link ByteBuffer} inbound {@link Flux} * * @return a {@link ByteBuffer} inbound {@link Flux} */ public final Flux<ByteBuffer> asByteBuffer() { return handle((bb, sink) -> { try { sink.next(bb.nioBuffer()); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@literal byte[]} inbound {@link Flux} * * @return a {@literal byte[]} inbound {@link Flux} */ public final Flux<byte[]> asByteArray() { return handle((bb, sink) -> { try { byte[] bytes = new byte[bb.readableBytes()]; bb.readBytes(bytes); sink.next(bytes); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@link String} inbound {@link Flux} using the provided {@link Charset}. * * @param charset the decoding charset * * @return a {@link String} inbound {@link Flux} */ public final Flux<String> asString(Charset charset) { return handle((bb, sink) -> { try { sink.next(bb.readCharSequence(bb.readableBytes(), charset).toString()); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@link String} inbound {@link Flux} using the provided {@link Charset}. * * @param charset the decoding charset * * @return a {@link String} inbound {@link Flux} */ public final Flux<String> asString(Charset charset) { return handle((bb, sink) -> { try { sink.next(bb.readCharSequence(bb.readableBytes(), charset).toString()); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@link InputStream} inbound {@link Flux} * * @return a {@link InputStream} inbound {@link Flux} */ public Flux<InputStream> asInputStream() { return handle((bb, sink) -> { try { sink.next(new ByteBufMono.ReleasingInputStream(bb)); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }
/** * Convert to a {@link InputStream} inbound {@link Flux} * * @return a {@link InputStream} inbound {@link Flux} */ public Flux<InputStream> asInputStream() { return handle((bb, sink) -> { try { sink.next(new ByteBufMono.ReleasingInputStream(bb)); } catch (IllegalReferenceCountException e) { sink.complete(); } }); }