Skip to content

Commit

Permalink
rename buffer with to_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles-Schleich committed Jan 10, 2025
1 parent 7768203 commit 6240bfd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions zenoh-ts/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ export class Publisher {
let _attachment = null;
if (put_options.attachment != null) {
let att_bytes = new ZBytes(put_options.attachment);
_attachment = Array.from(att_bytes.buffer());
_attachment = Array.from(att_bytes.to_bytes());
}

return this._remote_publisher.put(
Array.from(zbytes.buffer()),
Array.from(zbytes.to_bytes()),
_attachment,
_encoding.toString(),
_timestamp,
Expand Down Expand Up @@ -353,7 +353,7 @@ export class Publisher {
let _attachment = null;
if (delete_options.attachment != null) {
let att_bytes = new ZBytes(delete_options.attachment);
_attachment = Array.from(att_bytes.buffer());
_attachment = Array.from(att_bytes.to_bytes());
}

let _timestamp = null;
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/querier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ export class Querier {
let _encoding = get_options?.encoding?.toString()

if (get_options?.attachment != undefined) {
_attachment = Array.from(new ZBytes(get_options?.attachment).buffer())
_attachment = Array.from(new ZBytes(get_options?.attachment).to_bytes())
}
if (get_options?.payload != undefined) {
_payload = Array.from(new ZBytes(get_options?.payload).buffer())
_payload = Array.from(new ZBytes(get_options?.payload).to_bytes())
}
if (get_options?.parameters != undefined) {
_parameters = get_options?.parameters;
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class Query {
let qr_variant: QueryReplyVariant = {
Reply: {
key_expr: _key_expr.toString(),
payload: b64_str_from_bytes(z_bytes.buffer()),
payload: b64_str_from_bytes(z_bytes.to_bytes()),

},
};
Expand All @@ -258,7 +258,7 @@ export class Query {
reply_err(payload: IntoZBytes): void {
let z_bytes: ZBytes = new ZBytes(payload);
let qr_variant: QueryReplyVariant = {
ReplyErr: { payload: b64_str_from_bytes(z_bytes.buffer()) },
ReplyErr: { payload: b64_str_from_bytes(z_bytes.to_bytes()) },
};
this.reply_ws(qr_variant);
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ts/src/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export function SampleWS_from_Sample(
attachement: ZBytes | undefined,
): SampleWS {
let key_expr: OwnedKeyExprWrapper = sample.keyexpr().toString();
let value: Array<number> = Array.from(sample.payload().buffer());
let value: Array<number> = Array.from(sample.payload().to_bytes());

let sample_kind: SampleKindWS;
if (sample.kind() == SampleKind.DELETE) {
Expand All @@ -344,7 +344,7 @@ export function SampleWS_from_Sample(

let attach = null;
if (attachement != null) {
attach = b64_str_from_bytes(new Uint8Array(attachement.buffer()));
attach = b64_str_from_bytes(new Uint8Array(attachement.to_bytes()));
}

let sample_ws: SampleWS = {
Expand Down
10 changes: 5 additions & 5 deletions zenoh-ts/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ export class Session {
_express = put_opts?.express?.valueOf();

if (put_opts?.attachment != undefined) {
_attachment = Array.from(new ZBytes(put_opts?.attachment).buffer())
_attachment = Array.from(new ZBytes(put_opts?.attachment).to_bytes())
}

this.remote_session.put(
key_expr.toString(),
Array.from(z_bytes.buffer()),
Array.from(z_bytes.to_bytes()),
_encoding,
_congestion_control,
_priority,
Expand Down Expand Up @@ -296,7 +296,7 @@ export class Session {
let _timestamp;

if (delete_opts?.attachment != undefined) {
_attachment = Array.from(new ZBytes(delete_opts?.attachment).buffer())
_attachment = Array.from(new ZBytes(delete_opts?.attachment).to_bytes())
}

if (delete_opts?.timestamp != undefined) {
Expand Down Expand Up @@ -398,10 +398,10 @@ export class Session {
_timeout_millis = Duration.milliseconds.from(get_options?.timeout);
}
if (get_options?.attachment != undefined) {
_attachment = Array.from(new ZBytes(get_options?.attachment).buffer())
_attachment = Array.from(new ZBytes(get_options?.attachment).to_bytes())
}
if (get_options?.payload != undefined) {
_payload = Array.from(new ZBytes(get_options?.payload).buffer())
_payload = Array.from(new ZBytes(get_options?.payload).to_bytes())
}

let chan: SimpleChannel<ReplyWS> = this.remote_session.get(
Expand Down
7 changes: 3 additions & 4 deletions zenoh-ts/src/z_bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ export class ZBytes {
}

/**
* returns the length of the ZBytes buffer
* returns if the ZBytes Buffer is empty
*
* @returns number
* @returns boolean
*/
is_empty(): boolean {
return this._buffer.length == 0;
}


/**
* returns an empty ZBytes buffer
*
Expand All @@ -82,7 +81,7 @@ export class ZBytes {
*
* @returns Uint8Array
*/
buffer(): Uint8Array {
to_bytes(): Uint8Array {
return this._buffer
}

Expand Down

0 comments on commit 6240bfd

Please sign in to comment.