All files / json-pack/src/nfs/v4 Nfsv4Encoder.ts

90.9% Statements 10/11
100% Branches 1/1
80% Functions 4/5
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3728x 28x       28x     625x 625x             75x 75x       765x             6x 6x              
import {Writer} from '@jsonjoy.com/buffers/lib/Writer';
import {XdrEncoder} from '../../xdr/XdrEncoder';
import type * as msg from './messages';
import type {IWriter, IWriterGrowable} from '@jsonjoy.com/buffers';
 
export class Nfsv4Encoder<W extends IWriter & IWriterGrowable = IWriter & IWriterGrowable> {
  public readonly xdr: XdrEncoder;
 
  constructor(public readonly writer: W = new Writer() as any) {
    this.xdr = new XdrEncoder(writer);
  }
 
  public encodeCompound(
    compound: msg.Nfsv4CompoundRequest | msg.Nfsv4CompoundResponse,
    isRequest?: boolean,
  ): Uint8Array {
    compound.encode(this.xdr);
    return this.writer.flush();
  }
 
  public writeCompound(compound: msg.Nfsv4CompoundRequest | msg.Nfsv4CompoundResponse, isRequest: boolean): void {
    compound.encode(this.xdr);
  }
 
  public encodeCbCompound(
    compound: msg.Nfsv4CbCompoundRequest | msg.Nfsv4CbCompoundResponse,
    isRequest?: boolean,
  ): Uint8Array {
    compound.encode(this.xdr);
    return this.writer.flush();
  }
 
  public writeCbCompound(compound: msg.Nfsv4CbCompoundRequest | msg.Nfsv4CbCompoundResponse, isRequest: boolean): void {
    compound.encode(this.xdr);
  }
}