project_note
Clone
https://git.tahinli.com/Tahinli/project_note.git
0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits
| 1 | use Either; |
| 2 | /* |
| 3 | This file is modified from the original file in the following repo: |
| 4 | https://github.com/zed-industries/zed |
| 5 | |
| 6 | |
| 7 | Copyright 2022 - 2024 Zed Industries, Inc. |
| 8 | |
| 9 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | you may not use this file except in compliance with the License. |
| 11 | You may obtain a copy of the License at |
| 12 | |
| 13 | |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | |
| 17 | Unless required by applicable law or agreed to in writing, software |
| 18 | distributed under the License is distributed on an "AS IS" BASIS, |
| 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | See the License for the specific language governing permissions and |
| 21 | limitations under the License. |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | Apache License |
| 27 | Version 2.0, January 2004 |
| 28 | http://www.apache.org/licenses/ |
| 29 | |
| 30 | |
| 31 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
| 32 | |
| 33 | |
| 34 | 1. Definitions. |
| 35 | |
| 36 | |
| 37 | "License" shall mean the terms and conditions for use, reproduction, |
| 38 | and distribution as defined by Sections 1 through 9 of this document. |
| 39 | |
| 40 | |
| 41 | "Licensor" shall mean the copyright owner or entity authorized by |
| 42 | the copyright owner that is granting the License. |
| 43 | |
| 44 | |
| 45 | "Legal Entity" shall mean the union of the acting entity and all |
| 46 | other entities that control, are controlled by, or are under common |
| 47 | control with that entity. For the purposes of this definition, |
| 48 | "control" means (i) the power, direct or indirect, to cause the |
| 49 | direction or management of such entity, whether by contract or |
| 50 | otherwise, or (ii) ownership of fifty percent (50%) or more of the |
| 51 | outstanding shares, or (iii) beneficial ownership of such entity. |
| 52 | |
| 53 | |
| 54 | "You" (or "Your") shall mean an individual or Legal Entity |
| 55 | exercising permissions granted by this License. |
| 56 | |
| 57 | |
| 58 | "Source" form shall mean the preferred form for making modifications, |
| 59 | including but not limited to software source code, documentation |
| 60 | source, and configuration files. |
| 61 | |
| 62 | |
| 63 | "Object" form shall mean any form resulting from mechanical |
| 64 | transformation or translation of a Source form, including but |
| 65 | not limited to compiled object code, generated documentation, |
| 66 | and conversions to other media types. |
| 67 | |
| 68 | |
| 69 | "Work" shall mean the work of authorship, whether in Source or |
| 70 | Object form, made available under the License, as indicated by a |
| 71 | copyright notice that is included in or attached to the work |
| 72 | (an example is provided in the Appendix below). |
| 73 | |
| 74 | |
| 75 | "Derivative Works" shall mean any work, whether in Source or Object |
| 76 | form, that is based on (or derived from) the Work and for which the |
| 77 | editorial revisions, annotations, elaborations, or other modifications |
| 78 | represent, as a whole, an original work of authorship. For the purposes |
| 79 | of this License, Derivative Works shall not include works that remain |
| 80 | separable from, or merely link (or bind by name) to the interfaces of, |
| 81 | the Work and Derivative Works thereof. |
| 82 | |
| 83 | |
| 84 | "Contribution" shall mean any work of authorship, including |
| 85 | the original version of the Work and any modifications or additions |
| 86 | to that Work or Derivative Works thereof, that is intentionally |
| 87 | submitted to Licensor for inclusion in the Work by the copyright owner |
| 88 | or by an individual or Legal Entity authorized to submit on behalf of |
| 89 | the copyright owner. For the purposes of this definition, "submitted" |
| 90 | means any form of electronic, verbal, or written communication sent |
| 91 | to the Licensor or its representatives, including but not limited to |
| 92 | communication on electronic mailing lists, source code control systems, |
| 93 | and issue tracking systems that are managed by, or on behalf of, the |
| 94 | Licensor for the purpose of discussing and improving the Work, but |
| 95 | excluding communication that is conspicuously marked or otherwise |
| 96 | designated in writing by the copyright owner as "Not a Contribution." |
| 97 | |
| 98 | |
| 99 | "Contributor" shall mean Licensor and any individual or Legal Entity |
| 100 | on behalf of whom a Contribution has been received by Licensor and |
| 101 | subsequently incorporated within the Work. |
| 102 | |
| 103 | |
| 104 | 2. Grant of Copyright License. Subject to the terms and conditions of |
| 105 | this License, each Contributor hereby grants to You a perpetual, |
| 106 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 107 | copyright license to reproduce, prepare Derivative Works of, |
| 108 | publicly display, publicly perform, sublicense, and distribute the |
| 109 | Work and such Derivative Works in Source or Object form. |
| 110 | |
| 111 | |
| 112 | 3. Grant of Patent License. Subject to the terms and conditions of |
| 113 | this License, each Contributor hereby grants to You a perpetual, |
| 114 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 115 | (except as stated in this section) patent license to make, have made, |
| 116 | use, offer to sell, sell, import, and otherwise transfer the Work, |
| 117 | where such license applies only to those patent claims licensable |
| 118 | by such Contributor that are necessarily infringed by their |
| 119 | Contribution(s) alone or by combination of their Contribution(s) |
| 120 | with the Work to which such Contribution(s) was submitted. If You |
| 121 | institute patent litigation against any entity (including a |
| 122 | cross-claim or counterclaim in a lawsuit) alleging that the Work |
| 123 | or a Contribution incorporated within the Work constitutes direct |
| 124 | or contributory patent infringement, then any patent licenses |
| 125 | granted to You under this License for that Work shall terminate |
| 126 | as of the date such litigation is filed. |
| 127 | |
| 128 | |
| 129 | 4. Redistribution. You may reproduce and distribute copies of the |
| 130 | Work or Derivative Works thereof in any medium, with or without |
| 131 | modifications, and in Source or Object form, provided that You |
| 132 | meet the following conditions: |
| 133 | |
| 134 | |
| 135 | (a) You must give any other recipients of the Work or |
| 136 | Derivative Works a copy of this License; and |
| 137 | |
| 138 | |
| 139 | (b) You must cause any modified files to carry prominent notices |
| 140 | stating that You changed the files; and |
| 141 | |
| 142 | |
| 143 | (c) You must retain, in the Source form of any Derivative Works |
| 144 | that You distribute, all copyright, patent, trademark, and |
| 145 | attribution notices from the Source form of the Work, |
| 146 | excluding those notices that do not pertain to any part of |
| 147 | the Derivative Works; and |
| 148 | |
| 149 | |
| 150 | (d) If the Work includes a "NOTICE" text file as part of its |
| 151 | distribution, then any Derivative Works that You distribute must |
| 152 | include a readable copy of the attribution notices contained |
| 153 | within such NOTICE file, excluding those notices that do not |
| 154 | pertain to any part of the Derivative Works, in at least one |
| 155 | of the following places: within a NOTICE text file distributed |
| 156 | as part of the Derivative Works; within the Source form or |
| 157 | documentation, if provided along with the Derivative Works; or, |
| 158 | within a display generated by the Derivative Works, if and |
| 159 | wherever such third-party notices normally appear. The contents |
| 160 | of the NOTICE file are for informational purposes only and |
| 161 | do not modify the License. You may add Your own attribution |
| 162 | notices within Derivative Works that You distribute, alongside |
| 163 | or as an addendum to the NOTICE text from the Work, provided |
| 164 | that such additional attribution notices cannot be construed |
| 165 | as modifying the License. |
| 166 | |
| 167 | |
| 168 | You may add Your own copyright statement to Your modifications and |
| 169 | may provide additional or different license terms and conditions |
| 170 | for use, reproduction, or distribution of Your modifications, or |
| 171 | for any such Derivative Works as a whole, provided Your use, |
| 172 | reproduction, and distribution of the Work otherwise complies with |
| 173 | the conditions stated in this License. |
| 174 | |
| 175 | |
| 176 | 5. Submission of Contributions. Unless You explicitly state otherwise, |
| 177 | any Contribution intentionally submitted for inclusion in the Work |
| 178 | by You to the Licensor shall be under the terms and conditions of |
| 179 | this License, without any additional terms or conditions. |
| 180 | Notwithstanding the above, nothing herein shall supersede or modify |
| 181 | the terms of any separate license agreement you may have executed |
| 182 | with Licensor regarding such Contributions. |
| 183 | |
| 184 | |
| 185 | 6. Trademarks. This License does not grant permission to use the trade |
| 186 | names, trademarks, service marks, or product names of the Licensor, |
| 187 | except as required for reasonable and customary use in describing the |
| 188 | origin of the Work and reproducing the content of the NOTICE file. |
| 189 | |
| 190 | |
| 191 | 7. Disclaimer of Warranty. Unless required by applicable law or |
| 192 | agreed to in writing, Licensor provides the Work (and each |
| 193 | Contributor provides its Contributions) on an "AS IS" BASIS, |
| 194 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 195 | implied, including, without limitation, any warranties or conditions |
| 196 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
| 197 | PARTICULAR PURPOSE. You are solely responsible for determining the |
| 198 | appropriateness of using or redistributing the Work and assume any |
| 199 | risks associated with Your exercise of permissions under this License. |
| 200 | |
| 201 | |
| 202 | 8. Limitation of Liability. In no event and under no legal theory, |
| 203 | whether in tort (including negligence), contract, or otherwise, |
| 204 | unless required by applicable law (such as deliberate and grossly |
| 205 | negligent acts) or agreed to in writing, shall any Contributor be |
| 206 | liable to You for damages, including any direct, indirect, special, |
| 207 | incidental, or consequential damages of any character arising as a |
| 208 | result of this License or out of the use or inability to use the |
| 209 | Work (including but not limited to damages for loss of goodwill, |
| 210 | work stoppage, computer failure or malfunction, or any and all |
| 211 | other commercial damages or losses), even if such Contributor |
| 212 | has been advised of the possibility of such damages. |
| 213 | |
| 214 | |
| 215 | 9. Accepting Warranty or Additional Liability. While redistributing |
| 216 | the Work or Derivative Works thereof, You may choose to offer, |
| 217 | and charge a fee for, acceptance of support, warranty, indemnity, |
| 218 | or other liability obligations and/or rights consistent with this |
| 219 | License. However, in accepting such obligations, You may act only |
| 220 | on Your own behalf and on Your sole responsibility, not on behalf |
| 221 | of any other Contributor, and only if You agree to indemnify, |
| 222 | defend, and hold each Contributor harmless for any liability |
| 223 | incurred by, or claims asserted against, such Contributor by reason |
| 224 | of your accepting any such warranty or additional liability. |
| 225 | |
| 226 | |
| 227 | END OF TERMS AND CONDITIONS |
| 228 | |
| 229 | */ |
| 230 | use crate; |
| 231 | use SmallVec; |
| 232 | use ; |
| 233 | use Ordering; |
| 234 | use ; |
| 235 | use ; |
| 236 | use ThreadId; |
| 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 | type Callback = ; |
| 528 | |
| 529 | /// A handle to a subscription created by GPUI. When dropped, the subscription |
| 530 | /// is cancelled and the callback will no longer be invoked. |
| 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 | /// A wrapper around `SubscriberSet` that automatically handles recursive event emission. |
| 581 | /// |
| 582 | /// This struct differs from `SubscriberSet` in the following ways: |
| 583 | /// 1. It automatically handles the `CannotEmitEventDueToRecursiveCall` error that can occur in `SubscriberSet`. |
| 584 | /// 2. When a recursive event emission is detected, it queues the event instead of throwing an error. |
| 585 | /// 3. After the current event processing is complete, it automatically processes the queued events. |
| 586 | /// |
| 587 | /// This behavior ensures that all events are processed in the order they were emitted, even in cases |
| 588 | /// where recursive event emission would normally cause an error. |
| 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 | /// Runs steps that must all happen even if one of them panics, such as calling |
| 649 | /// every subscriber and delivering every event, and raises the first panic |
| 650 | /// once they are done. A subscriber is user code; its panic must not drop |
| 651 | /// events or local updates meant for others. |
| 652 | |
| 653 | pub ; |
| 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 |