davidliu
Committed by GitHub

Properly return Result on ByteStreamSender convenience methods (#709)

  1 +---
  2 +"client-sdk-android": patch
  3 +---
  4 +
  5 +Properly return Result on ByteStreamSender convenience methods
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 16
17 package io.livekit.android.room.datastream.outgoing 17 package io.livekit.android.room.datastream.outgoing
18 18
  19 +import androidx.annotation.CheckResult
19 import io.livekit.android.room.datastream.ByteStreamInfo 20 import io.livekit.android.room.datastream.ByteStreamInfo
20 import okio.Buffer 21 import okio.Buffer
21 import okio.FileSystem 22 import okio.FileSystem
@@ -53,20 +54,23 @@ private val byteDataChunker: DataChunker<ByteArray> = { data: ByteArray, chunkSi @@ -53,20 +54,23 @@ private val byteDataChunker: DataChunker<ByteArray> = { data: ByteArray, chunkSi
53 /** 54 /**
54 * Reads the file from [filePath] and writes it to the data stream. 55 * Reads the file from [filePath] and writes it to the data stream.
55 */ 56 */
56 -suspend fun ByteStreamSender.writeFile(filePath: String) {  
57 - write(FileSystem.SYSTEM.source(filePath.toPath())) 57 +@CheckResult
  58 +suspend fun ByteStreamSender.writeFile(filePath: String): Result<Unit> {
  59 + return write(FileSystem.SYSTEM.source(filePath.toPath()))
58 } 60 }
59 61
60 /** 62 /**
61 * Reads the input stream and sends it to the data stream. 63 * Reads the input stream and sends it to the data stream.
62 */ 64 */
63 -suspend fun ByteStreamSender.write(input: InputStream) {  
64 - write(input.source()) 65 +@CheckResult
  66 +suspend fun ByteStreamSender.write(input: InputStream): Result<Unit> {
  67 + return write(input.source())
65 } 68 }
66 69
67 /** 70 /**
68 * Reads the source and sends it to the data stream. 71 * Reads the source and sends it to the data stream.
69 */ 72 */
  73 +@CheckResult
70 suspend fun ByteStreamSender.write(source: Source): Result<Unit> { 74 suspend fun ByteStreamSender.write(source: Source): Result<Unit> {
71 val buffer = Buffer() 75 val buffer = Buffer()
72 while (true) { 76 while (true) {