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

99.07% Statements 643/649
100% Branches 45/45
98.61% Functions 214/217
99.2% Lines 621/626

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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396  31x                                                                                                                                                                         31x   7x 7x     14x     6x 6x       31x   9x 9x       4x 4x       31x   9x 9x       4x 4x 4x       31x   109x 109x 109x       218x 218x       109x 109x 109x       31x 216x     108x       31x   218x 218x       109x 109x 109x       31x   4x 4x 4x       8x 8x       4x 4x 4x       31x 3x     1x       31x   6x 6x       3x 3x 3x       31x   40x 40x 40x       20x 20x 20x 20x       31x   36x 36x       18x 18x       31x   40x 40x       20x 20x 20x       31x   1x 1x     2x     1x 1x       31x 2x     1x 1x       31x   1x 1x     2x     1x 1x       31x 2x     1x 1x       31x 118x     58x 58x       31x 109x     53x       31x   109x 109x       53x 53x 53x       31x   88x       31x 170x     84x       31x   170x 170x       84x 84x 84x       31x 10x     5x 5x       31x 8x     4x       31x   10x 10x       5x 5x 5x       31x   212x 212x 212x 212x 212x       107x 107x 107x 107x 107x 107x       31x 185x     93x       31x   24x 24x 24x 24x       12x 12x 12x 12x       31x   213x 213x 213x       107x 107x 107x 93x 14x 12x         31x   46x 46x 46x 46x       23x 23x 23x 23x 23x       31x   14x 14x 14x 14x       7x 7x 7x 7x       31x   44x 44x       22x 22x 22x       31x   27x 27x 27x 27x 27x       14x 14x 14x 14x 14x 14x       31x 21x     11x       31x   25x 25x       13x 13x 13x       31x 305x     153x 153x       31x 296x     147x 147x       31x   2x       31x 2x     1x 1x       31x 8x     4x 4x       31x 6x     3x 3x       31x   437x 437x 437x 437x 437x 437x       435x 435x 435x 435x 435x 435x 435x       31x   423x 423x 423x 423x 423x       212x 212x 212x 212x 212x       31x   438x 438x       219x 219x 219x 212x         31x 6x     3x 3x       31x 4x     2x 2x       31x   8x 8x       4x 4x 4x       31x 2x     1x       31x   6x 6x       3x 3x 3x 1x         31x   12x 12x 12x 12x       6x 6x 6x 6x 6x       31x 4x     2x       31x   10x 10x       5x 5x 5x 2x         31x 296x     147x 147x       31x 289x     142x 142x       31x   1x       31x                           31x   423x       31x 841x     420x 420x       31x   66x 66x 66x       33x 33x 33x 33x       31x   64x 64x       32x 32x       31x   64x 64x       32x 32x 32x 32x         31x   37x 37x 37x 37x 37x       15x 15x 15x 15x 15x 15x       31x   31x 31x 31x       13x 13x 13x 13x 21x 21x 21x   13x 13x       31x   31x 31x       13x 13x 13x 13x         31x   5x       31x 6x     3x       31x   8x 8x       4x 4x 4x 3x         31x 54x     27x 27x       31x 40x     20x       31x   54x 54x       27x 27x 27x 20x         31x   34x 34x       17x 17x 17x       31x   30x 30x       15x 15x       31x   34x 34x       17x 17x 17x       31x 2x     1x 1x       31x 2x     1x 1x       31x   2x       31x 4x     2x 2x       31x   21x       31x 42x     21x 21x       31x 2x     1x 1x       31x 2x     1x 1x 1x 1x       31x   2x 2x       1x 1x 1x       31x   128x 128x       64x 64x 64x       31x 126x     62x       31x   128x 128x       64x 64x 64x       31x   5x 5x 5x       2x 2x 2x 2x       31x   5x 5x       2x 2x       31x   5x 5x       2x 2x 2x       31x   5x 5x       2x 2x 2x       31x 5x     2x 2x       31x 8x     4x 4x       31x 6x     3x 3x       31x   128x 128x 128x 128x       64x 64x 64x 64x 64x       31x   124x 124x 124x       62x 62x 62x       31x   126x 126x       63x 63x 63x       31x 2x     1x 1x       31x 2x     1x 1x       31x   6x       31x 10x     5x 5x       31x   1624x 1624x 1624x       810x 810x 810x 810x 810x 1663x       31x   1586x 1586x 1586x       789x 789x 789x 789x 789x 1622x                   31x   2x 2x       1x 1x 1x       31x 2x     1x       31x   2x 2x       1x 1x 1x 1x         31x   2x 2x 2x       1x 1x 1x 1x       31x 2x     1x 1x       31x   1x       31x 2x     1x 1x       31x   6x 6x 6x 6x       3x 3x 3x 3x 3x 3x 3x       31x   6x 6x 6x       3x 3x 3x 3x 3x 3x      
import {Nfsv4Stat, type Nfsv4LockType, Nfsv4Op, Nfsv4CbOp} from './constants';
import * as structs from './structs';
import type {XdrDecoder, XdrEncoder, XdrType} from '../../xdr';
 
export type Nfsv4Operation = Nfsv4Request | Nfsv4Response;
 
export type Nfsv4Request =
  | Nfsv4AccessRequest
  | Nfsv4CloseRequest
  | Nfsv4CommitRequest
  | Nfsv4CreateRequest
  | Nfsv4DelegpurgeRequest
  | Nfsv4DelegreturnRequest
  | Nfsv4GetattrRequest
  | Nfsv4GetfhRequest
  | Nfsv4LinkRequest
  | Nfsv4LockRequest
  | Nfsv4LocktRequest
  | Nfsv4LockuRequest
  | Nfsv4LookupRequest
  | Nfsv4LookuppRequest
  | Nfsv4NverifyRequest
  | Nfsv4OpenRequest
  | Nfsv4OpenattrRequest
  | Nfsv4OpenConfirmRequest
  | Nfsv4OpenDowngradeRequest
  | Nfsv4PutfhRequest
  | Nfsv4PutpubfhRequest
  | Nfsv4PutrootfhRequest
  | Nfsv4ReadRequest
  | Nfsv4ReaddirRequest
  | Nfsv4ReadlinkRequest
  | Nfsv4RemoveRequest
  | Nfsv4RenameRequest
  | Nfsv4RenewRequest
  | Nfsv4RestorefhRequest
  | Nfsv4SavefhRequest
  | Nfsv4SecinfoRequest
  | Nfsv4SetattrRequest
  | Nfsv4SetclientidRequest
  | Nfsv4SetclientidConfirmRequest
  | Nfsv4VerifyRequest
  | Nfsv4WriteRequest
  | Nfsv4ReleaseLockOwnerRequest
  | Nfsv4IllegalRequest;
 
export type Nfsv4Response =
  | Nfsv4AccessResponse
  | Nfsv4CloseResponse
  | Nfsv4CommitResponse
  | Nfsv4CreateResponse
  | Nfsv4DelegpurgeResponse
  | Nfsv4DelegreturnResponse
  | Nfsv4GetattrResponse
  | Nfsv4GetfhResponse
  | Nfsv4LinkResponse
  | Nfsv4LockResponse
  | Nfsv4LocktResponse
  | Nfsv4LockuResponse
  | Nfsv4LookupResponse
  | Nfsv4LookuppResponse
  | Nfsv4NverifyResponse
  | Nfsv4OpenResponse
  | Nfsv4OpenattrResponse
  | Nfsv4OpenConfirmResponse
  | Nfsv4OpenDowngradeResponse
  | Nfsv4PutfhResponse
  | Nfsv4PutpubfhResponse
  | Nfsv4PutrootfhResponse
  | Nfsv4ReadResponse
  | Nfsv4ReaddirResponse
  | Nfsv4ReadlinkResponse
  | Nfsv4RemoveResponse
  | Nfsv4RenameResponse
  | Nfsv4RenewResponse
  | Nfsv4RestorefhResponse
  | Nfsv4SavefhResponse
  | Nfsv4SecinfoResponse
  | Nfsv4SetattrResponse
  | Nfsv4SetclientidResponse
  | Nfsv4SetclientidConfirmResponse
  | Nfsv4VerifyResponse
  | Nfsv4WriteResponse
  | Nfsv4ReleaseLockOwnerResponse
  | Nfsv4IllegalResponse;
 
export class Nfsv4AccessRequest implements XdrType {
  static decode(xdr: XdrDecoder): Nfsv4AccessRequest {
    const access = xdr.readUnsignedInt();
    return new Nfsv4AccessRequest(access);
  }
 
  constructor(public readonly access: number) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.ACCESS);
    xdr.writeUnsignedInt(this.access);
  }
}
 
export class Nfsv4AccessResOk {
  constructor(
    public readonly supported: number,
    public readonly access: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(this.supported);
    xdr.writeUnsignedInt(this.access);
  }
}
 
export class Nfsv4AccessResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4AccessResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.ACCESS);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4CloseRequest {
  static decode(xdr: XdrDecoder): Nfsv4CloseRequest {
    const seqid = xdr.readUnsignedInt();
    const openStateid = structs.Nfsv4Stateid.decode(xdr);
    return new Nfsv4CloseRequest(seqid, openStateid);
  }
 
  constructor(
    public readonly seqid: number,
    public readonly openStateid: structs.Nfsv4Stateid,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.CLOSE);
    xdr.writeUnsignedInt(this.seqid);
    this.openStateid.encode(xdr);
  }
}
 
export class Nfsv4CloseResOk {
  constructor(public readonly openStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    this.openStateid.encode(xdr);
  }
}
 
export class Nfsv4CloseResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4CloseResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.CLOSE);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4CommitRequest implements XdrType {
  public static decode(xdr: XdrDecoder): Nfsv4CommitRequest {
    const offset = xdr.readUnsignedHyper();
    const count = xdr.readUnsignedInt();
    return new Nfsv4CommitRequest(offset, count);
  }
 
  constructor(
    public readonly offset: bigint,
    public readonly count: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.COMMIT);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedInt(this.count);
  }
}
 
export class Nfsv4CommitResOk {
  constructor(public readonly writeverf: structs.Nfsv4Verifier) {}
 
  encode(xdr: XdrEncoder): void {
    this.writeverf.encode(xdr);
  }
}
 
export class Nfsv4CommitResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4CommitResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.COMMIT);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4CreateRequest implements XdrType {
  constructor(
    public readonly objtype: structs.Nfsv4CreateType,
    public readonly objname: string,
    public readonly createattrs: structs.Nfsv4Fattr,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.CREATE);
    this.objtype.encode(xdr);
    xdr.writeStr(this.objname);
    this.createattrs.encode(xdr);
  }
}
 
export class Nfsv4CreateResOk {
  constructor(
    public readonly cinfo: structs.Nfsv4ChangeInfo,
    public readonly attrset: structs.Nfsv4Bitmap,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    this.cinfo.encode(xdr);
    this.attrset.encode(xdr);
  }
}
 
export class Nfsv4CreateResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4CreateResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.CREATE);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4DelegpurgeRequest implements XdrType {
  static decode(xdr: XdrDecoder): Nfsv4DelegpurgeRequest {
    const clientid = xdr.readUnsignedHyper();
    return new Nfsv4DelegpurgeRequest(clientid);
  }
 
  constructor(public readonly clientid: bigint) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.DELEGPURGE);
    xdr.writeUnsignedHyper(this.clientid);
  }
}
 
export class Nfsv4DelegpurgeResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.DELEGPURGE);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4DelegreturnRequest implements XdrType {
  static decode(xdr: XdrDecoder): Nfsv4DelegreturnRequest {
    const delegStateid = structs.Nfsv4Stateid.decode(xdr);
    return new Nfsv4DelegreturnRequest(delegStateid);
  }
 
  constructor(public readonly delegStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.DELEGRETURN);
    this.delegStateid.encode(xdr);
  }
}
 
export class Nfsv4DelegreturnResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.DELEGRETURN);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4GetattrRequest implements XdrType {
  constructor(public readonly attrRequest: structs.Nfsv4Bitmap) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.GETATTR);
    this.attrRequest.encode(xdr);
  }
}
 
export class Nfsv4GetattrResOk {
  constructor(public readonly objAttributes: structs.Nfsv4Fattr) {}
 
  encode(xdr: XdrEncoder): void {
    this.objAttributes.encode(xdr);
  }
}
 
export class Nfsv4GetattrResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4GetattrResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.GETATTR);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4GetfhRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.GETFH);
  }
}
 
export class Nfsv4GetfhResOk {
  constructor(public readonly object: structs.Nfsv4Fh) {}
 
  encode(xdr: XdrEncoder): void {
    this.object.encode(xdr);
  }
}
 
export class Nfsv4GetfhResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4GetfhResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.GETFH);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4LinkRequest implements XdrType {
  constructor(public readonly newname: string) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LINK);
    xdr.writeStr(this.newname);
  }
}
 
export class Nfsv4LinkResOk {
  constructor(public readonly cinfo: structs.Nfsv4ChangeInfo) {}
 
  encode(xdr: XdrEncoder): void {
    this.cinfo.encode(xdr);
  }
}
 
export class Nfsv4LinkResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4LinkResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LINK);
    xdr.writeUnsignedInt(this.status);
    if (this.status === 0) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4LockRequest implements XdrType {
  constructor(
    public readonly locktype: Nfsv4LockType,
    public readonly reclaim: boolean,
    public readonly offset: bigint,
    public readonly length: bigint,
    public readonly locker: structs.Nfsv4LockOwnerInfo,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCK);
    xdr.writeUnsignedInt(this.locktype);
    xdr.writeBoolean(this.reclaim);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedHyper(this.length);
    this.locker.encode(xdr);
  }
}
 
export class Nfsv4LockResOk {
  constructor(public readonly lockStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    this.lockStateid.encode(xdr);
  }
}
 
export class Nfsv4LockResDenied {
  constructor(
    public readonly offset: bigint,
    public readonly length: bigint,
    public readonly locktype: Nfsv4LockType,
    public readonly owner: structs.Nfsv4LockOwner,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedHyper(this.length);
    xdr.writeUnsignedInt(this.locktype);
    this.owner.encode(xdr);
  }
}
 
export class Nfsv4LockResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4LockResOk,
    public readonly denied?: Nfsv4LockResDenied,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCK);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    } else if (this.denied) {
      this.denied.encode(xdr);
    }
  }
}
 
export class Nfsv4LocktRequest implements XdrType {
  constructor(
    public readonly locktype: Nfsv4LockType,
    public readonly offset: bigint,
    public readonly length: bigint,
    public readonly owner: structs.Nfsv4LockOwner,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCKT);
    xdr.writeUnsignedInt(this.locktype);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedHyper(this.length);
    this.owner.encode(xdr);
  }
}
 
export class Nfsv4LocktResDenied {
  constructor(
    public readonly offset: bigint,
    public readonly length: bigint,
    public readonly locktype: Nfsv4LockType,
    public readonly owner: structs.Nfsv4LockOwner,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedHyper(this.length);
    xdr.writeUnsignedInt(this.locktype);
    this.owner.encode(xdr);
  }
}
 
export class Nfsv4LocktResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly denied?: Nfsv4LocktResDenied,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCKT);
    xdr.writeUnsignedInt(this.status);
    this.denied?.encode(xdr);
  }
}
 
export class Nfsv4LockuRequest implements XdrType {
  constructor(
    public readonly locktype: Nfsv4LockType,
    public readonly seqid: number,
    public readonly lockStateid: structs.Nfsv4Stateid,
    public readonly offset: bigint,
    public readonly length: bigint,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCKU);
    xdr.writeUnsignedInt(this.locktype);
    xdr.writeUnsignedInt(this.seqid);
    this.lockStateid.encode(xdr);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedHyper(this.length);
  }
}
 
export class Nfsv4LockuResOk {
  constructor(public readonly lockStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    this.lockStateid.encode(xdr);
  }
}
 
export class Nfsv4LockuResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4LockuResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOCKU);
    xdr.writeUnsignedInt(this.status);
    if (this.status === 0) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4LookupRequest implements XdrType {
  constructor(public readonly objname: string) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOOKUP);
    xdr.writeStr(this.objname);
  }
}
 
export class Nfsv4LookupResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOOKUP);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4LookuppRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOOKUPP);
  }
}
 
export class Nfsv4LookuppResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.LOOKUPP);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4NverifyRequest implements XdrType {
  constructor(public readonly objAttributes: structs.Nfsv4Fattr) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.NVERIFY);
    this.objAttributes.encode(xdr);
  }
}
 
export class Nfsv4NverifyResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.NVERIFY);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4OpenRequest implements XdrType {
  constructor(
    public readonly seqid: number,
    public readonly shareAccess: number,
    public readonly shareDeny: number,
    public readonly owner: structs.Nfsv4OpenOwner,
    public readonly openhow: structs.Nfsv4OpenHow,
    public readonly claim: structs.Nfsv4OpenClaim,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN);
    xdr.writeUnsignedInt(this.seqid);
    xdr.writeUnsignedInt(this.shareAccess);
    xdr.writeUnsignedInt(this.shareDeny);
    this.owner.encode(xdr);
    this.openhow.encode(xdr);
    this.claim.encode(xdr);
  }
}
 
export class Nfsv4OpenResOk {
  constructor(
    public readonly stateid: structs.Nfsv4Stateid,
    public readonly cinfo: structs.Nfsv4ChangeInfo,
    public readonly rflags: number,
    public readonly attrset: structs.Nfsv4Bitmap,
    public readonly delegation: structs.Nfsv4OpenDelegation,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    this.stateid.encode(xdr);
    this.cinfo.encode(xdr);
    xdr.writeUnsignedInt(this.rflags);
    this.attrset.encode(xdr);
    this.delegation.encode(xdr);
  }
}
 
export class Nfsv4OpenResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4OpenResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4OpenattrRequest implements XdrType {
  constructor(public readonly createdir: boolean) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPENATTR);
    xdr.writeBoolean(this.createdir);
  }
}
 
export class Nfsv4OpenattrResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPENATTR);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4OpenConfirmRequest implements XdrType {
  constructor(
    public readonly openStateid: structs.Nfsv4Stateid,
    public readonly seqid: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN_CONFIRM);
    this.openStateid.encode(xdr);
    xdr.writeUnsignedInt(this.seqid);
  }
}
 
export class Nfsv4OpenConfirmResOk {
  constructor(public readonly openStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    this.openStateid.encode(xdr);
  }
}
 
export class Nfsv4OpenConfirmResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4OpenConfirmResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN_CONFIRM);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4OpenDowngradeRequest implements XdrType {
  constructor(
    public readonly openStateid: structs.Nfsv4Stateid,
    public readonly seqid: number,
    public readonly shareAccess: number,
    public readonly shareDeny: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN_DOWNGRADE);
    this.openStateid.encode(xdr);
    xdr.writeUnsignedInt(this.seqid);
    xdr.writeUnsignedInt(this.shareAccess);
    xdr.writeUnsignedInt(this.shareDeny);
  }
}
 
export class Nfsv4OpenDowngradeResOk {
  constructor(public readonly openStateid: structs.Nfsv4Stateid) {}
 
  encode(xdr: XdrEncoder): void {
    this.openStateid.encode(xdr);
  }
}
 
export class Nfsv4OpenDowngradeResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4OpenDowngradeResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.OPEN_DOWNGRADE);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4PutfhRequest implements XdrType {
  constructor(public readonly object: structs.Nfsv4Fh) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTFH);
    this.object.encode(xdr);
  }
}
 
export class Nfsv4PutfhResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTFH);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4PutpubfhRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTPUBFH);
  }
}
 
export class Nfsv4PutpubfhResponse implements XdrType {
  static decode(xdr: XdrDecoder): Nfsv4PutpubfhResponse {
    const status = xdr.readUnsignedInt();
    return new Nfsv4PutpubfhResponse(status);
  }
 
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTPUBFH);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4PutrootfhRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTROOTFH);
  }
}
 
export class Nfsv4PutrootfhResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.PUTROOTFH);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4ReadRequest implements XdrType {
  constructor(
    public readonly stateid: structs.Nfsv4Stateid,
    public readonly offset: bigint,
    public readonly count: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READ);
    this.stateid.encode(xdr);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedInt(this.count);
  }
}
 
export class Nfsv4ReadResOk {
  constructor(
    public readonly eof: boolean,
    public readonly data: Uint8Array,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeBoolean(this.eof);
    xdr.writeVarlenOpaque(this.data);
  }
}
 
export class Nfsv4ReadResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4ReadResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READ);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4ReaddirRequest implements XdrType {
  constructor(
    public readonly cookie: bigint,
    public readonly cookieverf: structs.Nfsv4Verifier,
    public readonly dircount: number,
    public readonly maxcount: number,
    public readonly attrRequest: structs.Nfsv4Bitmap,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READDIR);
    xdr.writeUnsignedHyper(this.cookie);
    this.cookieverf.encode(xdr);
    xdr.writeUnsignedInt(this.dircount);
    xdr.writeUnsignedInt(this.maxcount);
    this.attrRequest.encode(xdr);
  }
}
 
export class Nfsv4ReaddirResOk {
  constructor(
    public readonly cookieverf: structs.Nfsv4Verifier,
    public readonly entries: structs.Nfsv4Entry[],
    public readonly eof: boolean,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    this.cookieverf.encode(xdr);
    const entries = this.entries;
    const length = entries.length;
    for (let i = 0; i < length; i++) {
      const entry = entries[i];
      xdr.writeBoolean(true);
      entry.encode(xdr);
    }
    xdr.writeBoolean(false);
    xdr.writeBoolean(this.eof);
  }
}
 
export class Nfsv4ReaddirResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4ReaddirResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READDIR);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4ReadlinkRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READLINK);
  }
}
 
export class Nfsv4ReadlinkResOk {
  constructor(public readonly link: string) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeStr(this.link);
  }
}
 
export class Nfsv4ReadlinkResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4ReadlinkResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.READLINK);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4RemoveRequest implements XdrType {
  constructor(public readonly target: string) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.REMOVE);
    xdr.writeStr(this.target);
  }
}
 
export class Nfsv4RemoveResOk {
  constructor(public readonly cinfo: structs.Nfsv4ChangeInfo) {}
 
  encode(xdr: XdrEncoder): void {
    this.cinfo.encode(xdr);
  }
}
 
export class Nfsv4RemoveResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4RemoveResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.REMOVE);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4RenameRequest implements XdrType {
  constructor(
    public readonly oldname: string,
    public readonly newname: string,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RENAME);
    xdr.writeStr(this.oldname);
    xdr.writeStr(this.newname);
  }
}
 
export class Nfsv4RenameResOk {
  constructor(
    public readonly sourceCinfo: structs.Nfsv4ChangeInfo,
    public readonly targetCinfo: structs.Nfsv4ChangeInfo,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    this.sourceCinfo.encode(xdr);
    this.targetCinfo.encode(xdr);
  }
}
 
export class Nfsv4RenameResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4RenameResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RENAME);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4RenewRequest implements XdrType {
  constructor(public readonly clientid: bigint) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RENEW);
    xdr.writeUnsignedHyper(this.clientid);
  }
}
 
export class Nfsv4RenewResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RENEW);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4RestorefhRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RESTOREFH);
  }
}
 
export class Nfsv4RestorefhResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RESTOREFH);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4SavefhRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SAVEFH);
  }
}
 
export class Nfsv4SavefhResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SAVEFH);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4SecinfoRequest implements XdrType {
  constructor(public readonly name: string) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SECINFO);
    xdr.writeStr(this.name);
  }
}
 
export class Nfsv4SecinfoResOk {
  constructor(public readonly flavors: structs.Nfsv4SecInfoFlavor[]) {}
 
  encode(xdr: XdrEncoder): void {
    const flavors = this.flavors;
    const len = flavors.length;
    xdr.writeUnsignedInt(len);
    for (let i = 0; i < len; i++) flavors[i].encode(xdr);
  }
}
 
export class Nfsv4SecinfoResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4SecinfoResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SECINFO);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) this.resok.encode(xdr);
  }
}
 
export class Nfsv4SetattrRequest implements XdrType {
  constructor(
    public readonly stateid: structs.Nfsv4Stateid,
    public readonly objAttributes: structs.Nfsv4Fattr,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETATTR);
    this.stateid.encode(xdr);
    this.objAttributes.encode(xdr);
  }
}
 
export class Nfsv4SetattrResOk {
  constructor(public readonly attrsset: structs.Nfsv4Bitmap) {}
 
  encode(xdr: XdrEncoder): void {
    this.attrsset.encode(xdr);
  }
}
 
export class Nfsv4SetattrResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4SetattrResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETATTR);
    xdr.writeUnsignedInt(this.status);
    this.resok?.encode(xdr);
  }
}
 
export class Nfsv4SetclientidRequest implements XdrType {
  constructor(
    public readonly client: structs.Nfsv4ClientId,
    public readonly callback: structs.Nfsv4CbClient,
    public readonly callbackIdent: number,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETCLIENTID);
    this.client.encode(xdr);
    this.callback.encode(xdr);
    xdr.writeUnsignedInt(this.callbackIdent);
  }
}
 
export class Nfsv4SetclientidResOk {
  constructor(
    public readonly clientid: bigint,
    public readonly setclientidConfirm: structs.Nfsv4Verifier,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedHyper(this.clientid);
    this.setclientidConfirm.encode(xdr);
  }
}
 
export class Nfsv4SetclientidResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4SetclientidResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETCLIENTID);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK) this.resok?.encode(xdr);
  }
}
 
export class Nfsv4SetclientidConfirmRequest implements XdrType {
  constructor(
    public readonly clientid: bigint,
    public readonly setclientidConfirm: structs.Nfsv4Verifier,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETCLIENTID_CONFIRM);
    xdr.writeUnsignedHyper(this.clientid);
    this.setclientidConfirm.encode(xdr);
  }
}
 
export class Nfsv4SetclientidConfirmResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.SETCLIENTID_CONFIRM);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4VerifyRequest implements XdrType {
  constructor(public readonly objAttributes: structs.Nfsv4Fattr) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.VERIFY);
    this.objAttributes.encode(xdr);
  }
}
 
export class Nfsv4VerifyResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.VERIFY);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4WriteRequest implements XdrType {
  constructor(
    public readonly stateid: structs.Nfsv4Stateid,
    public readonly offset: bigint,
    public readonly stable: number,
    public readonly data: Uint8Array,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.WRITE);
    this.stateid.encode(xdr);
    xdr.writeUnsignedHyper(this.offset);
    xdr.writeUnsignedInt(this.stable);
    xdr.writeVarlenOpaque(this.data);
  }
}
 
export class Nfsv4WriteResOk {
  constructor(
    public readonly count: number,
    public readonly committed: number,
    public readonly writeverf: structs.Nfsv4Verifier,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(this.count);
    xdr.writeUnsignedInt(this.committed);
    this.writeverf.encode(xdr);
  }
}
 
export class Nfsv4WriteResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4WriteResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.WRITE);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) this.resok.encode(xdr);
  }
}
 
export class Nfsv4ReleaseLockOwnerRequest implements XdrType {
  constructor(public readonly lockOwner: structs.Nfsv4LockOwner) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RELEASE_LOCKOWNER);
    this.lockOwner.encode(xdr);
  }
}
 
export class Nfsv4ReleaseLockOwnerResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.RELEASE_LOCKOWNER);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4IllegalRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.ILLEGAL);
  }
}
 
export class Nfsv4IllegalResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4Op.ILLEGAL);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4CompoundRequest implements XdrType {
  constructor(
    public readonly tag: string,
    public readonly minorversion: number,
    public readonly argarray: Nfsv4Request[],
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeStr(this.tag);
    xdr.writeUnsignedInt(this.minorversion);
    const argarray = this.argarray;
    const len = argarray.length;
    xdr.writeUnsignedInt(len);
    for (let i = 0; i < len; i++) argarray[i].encode(xdr);
  }
}
 
export class Nfsv4CompoundResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly tag: string,
    public readonly resarray: Nfsv4Response[],
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(this.status);
    xdr.writeStr(this.tag);
    const resarray = this.resarray;
    const len = resarray.length;
    xdr.writeUnsignedInt(len);
    for (let i = 0; i < len; i++) resarray[i].encode(xdr);
  }
}
 
export type Nfsv4CbOperation = Nfsv4CbRequest | Nfsv4CbResponse;
 
export type Nfsv4CbRequest = Nfsv4CbGetattrRequest | Nfsv4CbRecallRequest | Nfsv4CbIllegalRequest;
 
export type Nfsv4CbResponse = Nfsv4CbGetattrResponse | Nfsv4CbRecallResponse | Nfsv4CbIllegalResponse;
 
export class Nfsv4CbGetattrRequest implements XdrType {
  constructor(
    public readonly fh: structs.Nfsv4Fh,
    public readonly attrRequest: structs.Nfsv4Bitmap,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_GETATTR);
    this.fh.encode(xdr);
    this.attrRequest.encode(xdr);
  }
}
 
export class Nfsv4CbGetattrResOk {
  constructor(public readonly objAttributes: structs.Nfsv4Fattr) {}
 
  encode(xdr: XdrEncoder): void {
    this.objAttributes.encode(xdr);
  }
}
 
export class Nfsv4CbGetattrResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly resok?: Nfsv4CbGetattrResOk,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_GETATTR);
    xdr.writeUnsignedInt(this.status);
    if (this.status === Nfsv4Stat.NFS4_OK && this.resok) {
      this.resok.encode(xdr);
    }
  }
}
 
export class Nfsv4CbRecallRequest implements XdrType {
  constructor(
    public readonly stateid: structs.Nfsv4Stateid,
    public readonly truncate: boolean,
    public readonly fh: structs.Nfsv4Fh,
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_RECALL);
    this.stateid.encode(xdr);
    xdr.writeBoolean(this.truncate);
    this.fh.encode(xdr);
  }
}
 
export class Nfsv4CbRecallResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_RECALL);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4CbIllegalRequest implements XdrType {
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_ILLEGAL);
  }
}
 
export class Nfsv4CbIllegalResponse implements XdrType {
  constructor(public readonly status: Nfsv4Stat) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(Nfsv4CbOp.CB_ILLEGAL);
    xdr.writeUnsignedInt(this.status);
  }
}
 
export class Nfsv4CbCompoundRequest implements XdrType {
  constructor(
    public readonly tag: string,
    public readonly minorversion: number,
    public readonly callbackIdent: number,
    public readonly argarray: Nfsv4CbRequest[],
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeStr(this.tag);
    xdr.writeUnsignedInt(this.minorversion);
    xdr.writeUnsignedInt(this.callbackIdent);
    const argarray = this.argarray;
    const len = argarray.length;
    xdr.writeUnsignedInt(len);
    for (let i = 0; i < len; i++) argarray[i].encode(xdr);
  }
}
 
export class Nfsv4CbCompoundResponse implements XdrType {
  constructor(
    public readonly status: Nfsv4Stat,
    public readonly tag: string,
    public readonly resarray: Nfsv4CbResponse[],
  ) {}
 
  encode(xdr: XdrEncoder): void {
    xdr.writeUnsignedInt(this.status);
    xdr.writeStr(this.tag);
    const resarray = this.resarray;
    const len = resarray.length;
    xdr.writeUnsignedInt(len);
    for (let i = 0; i < len; i++) resarray[i].encode(xdr);
  }
}