Tabnine Logo
Frame.mapFrame
Code IndexAdd Tabnine to your IDE (free)

How to use
mapFrame
method
in
io.rsocket.framing.Frame

Best Java code snippets using io.rsocket.framing.Frame.mapFrame (Showing top 6 results out of 315)

origin: rsocket/rsocket-java

/**
 * Creates the frame with a stream id.
 *
 * @param byteBufAllocator the {@code ByteBufAllocator} to use
 * @param streamId the stream id
 * @param frame the frame to prepend the stream id to
 * @return the frame with a stream id
 * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null}
 */
public static StreamIdFrame createStreamIdFrame(
  ByteBufAllocator byteBufAllocator, int streamId, Frame frame) {
 Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null");
 Objects.requireNonNull(frame, "frame must not be null");
 ByteBuf streamIdByteBuf =
   frame.mapFrame(
     frameByteBuf -> {
      ByteBuf byteBuf = byteBufAllocator.buffer(STREAM_ID_BYTES).writeInt(streamId);
      return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain());
     });
 return RECYCLER.get().setByteBuf(streamIdByteBuf);
}
origin: rsocket/rsocket-java

/**
 * Creates the frame with a frame length.
 *
 * @param byteBufAllocator the {@link ByteBufAllocator} to use
 * @param frame the frame to prepend the frame length to
 * @return the frame with a frame length
 * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null}
 */
public static FrameLengthFrame createFrameLengthFrame(
  ByteBufAllocator byteBufAllocator, Frame frame) {
 Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null");
 Objects.requireNonNull(frame, "frame must not be null");
 ByteBuf frameLengthByteBuf =
   frame.mapFrame(
     frameByteBuf -> {
      ByteBuf byteBuf =
        byteBufAllocator
          .buffer(FRAME_LENGTH_BYTES)
          .writeMedium(getLengthAsUnsignedMedium(frameByteBuf));
      return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain());
     });
 return RECYCLER.get().setByteBuf(frameLengthByteBuf);
}
origin: rsocket/rsocket-java

@DisplayName("maps frame")
@Test
default void mapFrame() {
 Tuple2<T, ByteBuf> tuple = getFrame();
 T frame = tuple.getT1();
 ByteBuf byteBuf = tuple.getT2();
 assertThat(frame.mapFrame(Function.identity())).isEqualTo(byteBuf);
}
origin: rsocket/rsocket-java

 @DisplayName("mapFrame throws NullPointerException with null function")
 @Test
 default void mapFrameNullFunction() {
  Tuple2<T, ByteBuf> tuple = getFrame();
  T frame = tuple.getT1();

  assertThatNullPointerException()
    .isThrownBy(() -> frame.mapFrame(null))
    .withMessage("function must not be null");
 }
}
origin: io.rsocket/rsocket-core

/**
 * Creates the frame with a stream id.
 *
 * @param byteBufAllocator the {@code ByteBufAllocator} to use
 * @param streamId the stream id
 * @param frame the frame to prepend the stream id to
 * @return the frame with a stream id
 * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null}
 */
public static StreamIdFrame createStreamIdFrame(
  ByteBufAllocator byteBufAllocator, int streamId, Frame frame) {
 Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null");
 Objects.requireNonNull(frame, "frame must not be null");
 ByteBuf streamIdByteBuf =
   frame.mapFrame(
     frameByteBuf -> {
      ByteBuf byteBuf = byteBufAllocator.buffer(STREAM_ID_BYTES).writeInt(streamId);
      return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain());
     });
 return RECYCLER.get().setByteBuf(streamIdByteBuf);
}
origin: io.rsocket/rsocket-core

/**
 * Creates the frame with a frame length.
 *
 * @param byteBufAllocator the {@link ByteBufAllocator} to use
 * @param frame the frame to prepend the frame length to
 * @return the frame with a frame length
 * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null}
 */
public static FrameLengthFrame createFrameLengthFrame(
  ByteBufAllocator byteBufAllocator, Frame frame) {
 Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null");
 Objects.requireNonNull(frame, "frame must not be null");
 ByteBuf frameLengthByteBuf =
   frame.mapFrame(
     frameByteBuf -> {
      ByteBuf byteBuf =
        byteBufAllocator
          .buffer(FRAME_LENGTH_BYTES)
          .writeMedium(getLengthAsUnsignedMedium(frameByteBuf));
      return Unpooled.wrappedBuffer(byteBuf, frameByteBuf.retain());
     });
 return RECYCLER.get().setByteBuf(frameLengthByteBuf);
}
io.rsocket.framingFramemapFrame

Javadoc

Exposes the Frame as a ByteBuf for mapping to a different type.

Popular methods of Frame

  • getUnsafeFrame
    Returns the frame directly.Note: this frame will be outside of the Frame's lifecycle and may be rele
  • consumeFrame
    Exposes the Frame as a ByteBuf for consumption.

Popular in Java

  • Start an intent from android
  • getSystemService (Context)
  • putExtra (Intent)
  • getContentResolver (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now