// Code generated by protoc-gen-grpc-ts. DO NOT EDIT. // Generated from: container/types.proto import { NeoFsV2Refs } from '../refs/types_pb'; import { NeoFsV2Netmap } from '../netmap/types_pb'; type ChecksumType = NeoFsV2Refs.ChecksumType; class BinaryWriter { private buffer: Uint8Array = new Uint8Array(1024); private position: number = 0; private ensureCapacity(needed: number): void { if (this.position + needed > this.buffer.length) { const minSize = this.position + needed const newBuffer = new Uint8Array(Math.max(this.buffer.length * 2, minSize)) newBuffer.set(this.buffer); this.buffer = newBuffer; } } private writeVarint(value: number): void { while (value > 127) { this.ensureCapacity(1); this.buffer[this.position++] = (value & 127) | 128; value >>>= 7; } this.ensureCapacity(1); this.buffer[this.position++] = value & 127; } private writeVarintBigInt(value: bigint): void { while (value > 127n) { this.ensureCapacity(1); this.buffer[this.position++] = Number(value & 127n) | 128; value >>= 7n; } this.ensureCapacity(1); this.buffer[this.position++] = Number(value & 127n); } writeDouble(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 1); // wire type 1 this.ensureCapacity(8); const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 8); view.setFloat64(0, value, true); // little endian this.position += 8; } writeFloat(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 5); // wire type 5 this.ensureCapacity(4); const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 4); view.setFloat32(0, value, true); // little endian this.position += 4; } writeInt32(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } writeInt64(fieldNumber: number, value: bigint): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarintBigInt(value); } writeUint32(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } writeUint64(fieldNumber: number, value: bigint): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarintBigInt(value); } writeBool(fieldNumber: number, value: boolean): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value ? 1 : 0); } writeString(fieldNumber: number, value: string): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 const bytes = this.encodeString(value); this.writeVarint(bytes.length); this.ensureCapacity(bytes.length); this.buffer.set(bytes, this.position); this.position += bytes.length; } writeBytes(fieldNumber: number, value: Uint8Array): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 this.writeVarint(value.length); this.ensureCapacity(value.length); this.buffer.set(value, this.position); this.position += value.length; } writeMessage(fieldNumber: number, value: any): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 const bytes = value.serializeBinary(); this.writeVarint(bytes.length); this.ensureCapacity(bytes.length); this.buffer.set(bytes, this.position); this.position += bytes.length; } writeEnum(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } private encodeString(str: string): Uint8Array { // Manual UTF-8 encoding (React Native compatible) const bytes: number[] = []; for (let i = 0; i < str.length; i++) { let codePoint = str.charCodeAt(i); if (codePoint >= 0xD800 && codePoint <= 0xDBFF && i + 1 < str.length) { const next = str.charCodeAt(i + 1); if (next >= 0xDC00 && next <= 0xDFFF) { codePoint = 0x10000 + ((codePoint - 0xD800) << 10) + (next - 0xDC00); i++; } } if (codePoint < 0x80) { bytes.push(codePoint); } else if (codePoint < 0x800) { bytes.push(0xC0 | (codePoint >> 6), 0x80 | (codePoint & 0x3F)); } else if (codePoint < 0x10000) { bytes.push(0xE0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F)); } else { bytes.push(0xF0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3F), 0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F)); } } return new Uint8Array(bytes); } getResultBuffer(): Uint8Array { return this.buffer.slice(0, this.position); } } class BinaryReader { buffer: Uint8Array; position: number = 0; constructor(data: Uint8Array) { this.buffer = data; } readVarint(): number { let result = 0; let shift = 0; while (this.position < this.buffer.length) { const byte = this.buffer[this.position++]; result |= (byte & 127) << shift; if ((byte & 128) === 0) break; shift += 7; } return result; } readVarintBigInt(): bigint { let result = 0n; let shift = 0n; while (this.position < this.buffer.length) { const byte = BigInt(this.buffer[this.position++]); result |= (byte & 127n) << shift; if ((byte & 128n) === 0n) break; shift += 7n; } return result; } readDouble(): number { const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 8); this.position += 8; return view.getFloat64(0, true); // little endian } readFloat(): number { const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 4); this.position += 4; return view.getFloat32(0, true); // little endian } readInt32(): number { return this.readVarint(); } readInt64(): bigint { return this.readVarintBigInt(); } readUint32(): number { return this.readVarint(); } readUint64(): bigint { return this.readVarintBigInt(); } readBool(): boolean { return this.readVarint() !== 0; } readString(): string { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return this.decodeString(bytes); } private decodeString(bytes: Uint8Array): string { // Manual UTF-8 decoding (React Native compatible) let result = ''; let i = 0; while (i < bytes.length) { const byte1 = bytes[i++]; if (byte1 < 0x80) { result += String.fromCharCode(byte1); } else if ((byte1 & 0xE0) === 0xC0) { const byte2 = bytes[i++] & 0x3F; result += String.fromCharCode(((byte1 & 0x1F) << 6) | byte2); } else if ((byte1 & 0xF0) === 0xE0) { const byte2 = bytes[i++] & 0x3F; const byte3 = bytes[i++] & 0x3F; result += String.fromCharCode(((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3); } else if ((byte1 & 0xF8) === 0xF0) { const byte2 = bytes[i++] & 0x3F; const byte3 = bytes[i++] & 0x3F; const byte4 = bytes[i++] & 0x3F; const codePoint = ((byte1 & 0x07) << 18) | (byte2 << 12) | (byte3 << 6) | byte4; result += String.fromCharCode(0xD800 + ((codePoint - 0x10000) >> 10), 0xDC00 + ((codePoint - 0x10000) & 0x3FF)); } } return result; } readBytes(): Uint8Array { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return bytes; } readMessage(deserialize: (data: Uint8Array) => T): T { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return deserialize(bytes); } readEnum(): number { return this.readVarint(); } readInt32Fixed(): number { const bytes = this.buffer.slice(this.position, this.position + 4); this.position += 4; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getInt32(0, true); // little-endian } readInt64Fixed(): bigint { const bytes = this.buffer.slice(this.position, this.position + 8); this.position += 8; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getBigInt64(0, true); // little-endian } readUint32Fixed(): number { const bytes = this.buffer.slice(this.position, this.position + 4); this.position += 4; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getUint32(0, true); // little-endian } readUint64Fixed(): bigint { const bytes = this.buffer.slice(this.position, this.position + 8); this.position += 8; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getBigUint64(0, true); // little-endian } skipField(wireType: number): void { switch (wireType) { case 0: // Varint this.readVarint(); break; case 1: // 64-bit this.position += 8; break; case 2: // Length-delimited const length = this.readVarint(); this.position += length; break; case 3: // Start group (deprecated, just skip) // Groups are deprecated in proto3, skip without reading break; case 4: // End group (deprecated, just skip) // Groups are deprecated in proto3, skip without reading break; case 5: // 32-bit this.position += 4; break; default: throw new Error(`Unknown wire type: ${wireType}`); } } } export namespace NeoFsV2Container { export interface Container { Version?: NeoFsV2Refs.Version; OwnerId?: NeoFsV2Refs.OwnerID; Nonce: Uint8Array; BasicAcl: number; Attributes: Container_Attribute[]; PlacementPolicy?: NeoFsV2Netmap.PlacementPolicy; } export class ContainerImpl implements Container { Version?: NeoFsV2Refs.Version; OwnerId?: NeoFsV2Refs.OwnerID; Nonce!: Uint8Array; BasicAcl!: number; Attributes!: Container_Attribute[]; PlacementPolicy?: NeoFsV2Netmap.PlacementPolicy; constructor(data?: Partial) { this.Version = data?.Version ?? undefined; this.OwnerId = data?.OwnerId ?? undefined; this.Nonce = data?.Nonce ?? new Uint8Array(0); this.BasicAcl = data?.BasicAcl ?? 0; this.Attributes = data?.Attributes ?? []; this.PlacementPolicy = data?.PlacementPolicy ?? undefined; } serializeBinary(): Uint8Array { const writer = new BinaryWriter(); if (this.Version) { writer.writeMessage(1, this.Version); } if (this.OwnerId) { writer.writeMessage(2, this.OwnerId); } if (this.Nonce.length > 0) { writer.writeBytes(3, this.Nonce); } if (this.BasicAcl !== 0) { writer.writeUint32(4, this.BasicAcl); } for (const item of this.Attributes) { writer.writeMessage(5, item); } if (this.PlacementPolicy) { writer.writeMessage(6, this.PlacementPolicy); } return writer.getResultBuffer(); } static deserializeBinary(data: Uint8Array): ContainerImpl { const reader = new BinaryReader(data); const message = new ContainerImpl(); // Parse protobuf wire format while (reader.position < reader.buffer.length) { const tag = reader.readVarint(); const fieldNumber = tag >>> 3; const wireType = tag & 7; switch (fieldNumber) { case 1: // Version if (wireType === 2) { // Length-delimited message.Version = reader.readMessage(NeoFsV2Refs.VersionImpl.deserializeBinary); } else { reader.skipField(wireType); } break; case 2: // OwnerId if (wireType === 2) { // Length-delimited message.OwnerId = reader.readMessage(NeoFsV2Refs.OwnerIDImpl.deserializeBinary); } else { reader.skipField(wireType); } break; case 3: // Nonce if (wireType === 2) { // Length-delimited message.Nonce = reader.readBytes(); } else { reader.skipField(wireType); } break; case 4: // BasicAcl if (wireType === 0) { // Varint message.BasicAcl = reader.readUint32(); } else if (wireType === 5) { // 32-bit message.BasicAcl = reader.readUint32Fixed(); } else { reader.skipField(wireType); } break; case 5: // Attributes if (wireType === 2) { // Length-delimited message.Attributes.push(reader.readMessage(Container_AttributeImpl.deserializeBinary)); } else { reader.skipField(wireType); } break; case 6: // PlacementPolicy if (wireType === 2) { // Length-delimited message.PlacementPolicy = reader.readMessage(NeoFsV2Netmap.PlacementPolicyImpl.deserializeBinary); } else { reader.skipField(wireType); } break; default: // Skip unknown fields reader.skipField(wireType); break; } } return message; } toObject(): ContainerData { return { Version: this.Version, OwnerId: this.OwnerId, Nonce: this.Nonce, BasicAcl: this.BasicAcl, Attributes: this.Attributes, PlacementPolicy: this.PlacementPolicy }; } } // Export class alias without Impl suffix for Node.js compatibility export class Container extends ContainerImpl {} // Type for interface data only (excludes class methods from merged type) export type ContainerData = Omit; export interface Container_Attribute { Key: string; Value: string; } export class Container_AttributeImpl implements Container_Attribute { Key!: string; Value!: string; constructor(data?: Partial) { this.Key = data?.Key ?? ""; this.Value = data?.Value ?? ""; } serializeBinary(): Uint8Array { const writer = new BinaryWriter(); if (this.Key !== "") { writer.writeString(1, this.Key); } if (this.Value !== "") { writer.writeString(2, this.Value); } return writer.getResultBuffer(); } static deserializeBinary(data: Uint8Array): Container_AttributeImpl { const reader = new BinaryReader(data); const message = new Container_AttributeImpl(); // Parse protobuf wire format while (reader.position < reader.buffer.length) { const tag = reader.readVarint(); const fieldNumber = tag >>> 3; const wireType = tag & 7; switch (fieldNumber) { case 1: // Key if (wireType === 2) { // Length-delimited message.Key = reader.readString(); } else { reader.skipField(wireType); } break; case 2: // Value if (wireType === 2) { // Length-delimited message.Value = reader.readString(); } else { reader.skipField(wireType); } break; default: // Skip unknown fields reader.skipField(wireType); break; } } return message; } toObject(): Container_AttributeData { return { Key: this.Key, Value: this.Value }; } } // Export class alias without Impl suffix for Node.js compatibility export class Container_Attribute extends Container_AttributeImpl {} // Type for interface data only (excludes class methods from merged type) export type Container_AttributeData = Omit; } // namespace NeoFsV2Container