[{"data":1,"prerenderedAt":763},["ShallowReactive",2],{"navigation":3,"\u002Flocks\u002Fguard-state":151,"\u002Flocks\u002Fguard-state-surround":758},[4,29,56,79,94,121,128,144],{"title":5,"path":6,"stem":7,"children":8,"icon":27,"defaultOpen":28},"Getting Started","\u002Fgetting-started","1.getting-started\u002F1.index",[9,12,17,22],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-book-open",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Redis setup","\u002Fgetting-started\u002Fredis-setup","1.getting-started\u002F3.redis-setup","i-lucide-database",{"title":23,"path":24,"stem":25,"icon":26},"Quickstart","\u002Fgetting-started\u002Fquickstart","1.getting-started\u002F4.quickstart","i-lucide-zap","i-lucide-rocket",true,{"title":30,"icon":31,"path":32,"stem":33,"children":34,"page":55},"Concepts","i-lucide-lightbulb","\u002Fconcepts","2.concepts",[35,40,45,50],{"title":36,"path":37,"stem":38,"icon":39},"Keys","\u002Fconcepts\u002Fkeys","2.concepts\u002F1.keys","i-lucide-key-round",{"title":41,"path":42,"stem":43,"icon":44},"Strict vs lax","\u002Fconcepts\u002Fstrict-vs-lax","2.concepts\u002F2.strict-vs-lax","i-lucide-scale",{"title":46,"path":47,"stem":48,"icon":49},"Comparators","\u002Fconcepts\u002Fcomparators","2.concepts\u002F3.comparators","i-lucide-git-compare",{"title":51,"path":52,"stem":53,"icon":54},"Errors","\u002Fconcepts\u002Ferrors","2.concepts\u002F4.errors","i-lucide-triangle-alert",false,{"title":57,"path":58,"stem":59,"children":60,"icon":63},"Counters","\u002Fcounters","3.counters\u002F1.index",[61,64,69,74],{"title":62,"path":58,"stem":59,"icon":63},"Overview","i-lucide-hash",{"title":65,"path":66,"stem":67,"icon":68},"StrictCounter","\u002Fcounters\u002Fstrict-counter","3.counters\u002F2.strict-counter","i-lucide-target",{"title":70,"path":71,"stem":72,"icon":73},"LaxCounter","\u002Fcounters\u002Flax-counter","3.counters\u002F3.lax-counter","i-lucide-wind",{"title":75,"path":76,"stem":77,"icon":78},"Conditional & batch operations","\u002Fcounters\u002Fconditional-and-batch","3.counters\u002F4.conditional-and-batch","i-lucide-layers",{"title":80,"path":81,"stem":82,"children":83,"icon":85},"Instance-aware counters","\u002Finstance-aware-counters","4.instance-aware-counters\u002F1.index",[84,86,90],{"title":62,"path":81,"stem":82,"icon":85},"i-lucide-network",{"title":87,"path":88,"stem":89,"icon":68},"StrictInstanceAwareCounter","\u002Finstance-aware-counters\u002Fstrict","4.instance-aware-counters\u002F2.strict",{"title":91,"path":92,"stem":93,"icon":73},"LaxInstanceAwareCounter","\u002Finstance-aware-counters\u002Flax","4.instance-aware-counters\u002F3.lax",{"title":95,"path":96,"stem":97,"children":98,"icon":100},"Locks","\u002Flocks","5.locks\u002F1.index",[99,101,106,111,116],{"title":62,"path":96,"stem":97,"icon":100},"i-lucide-lock",{"title":102,"path":103,"stem":104,"icon":105},"Mutex","\u002Flocks\u002Fmutex","5.locks\u002F2.mutex","i-lucide-lock-keyhole",{"title":107,"path":108,"stem":109,"icon":110},"RwLock","\u002Flocks\u002Frwlock","5.locks\u002F3.rwlock","i-lucide-book-lock",{"title":112,"path":113,"stem":114,"icon":115},"Lock options","\u002Flocks\u002Foptions","5.locks\u002F4.options","i-lucide-sliders-horizontal",{"title":117,"path":118,"stem":119,"icon":120},"Guard state & errors","\u002Flocks\u002Fguard-state","5.locks\u002F5.guard-state","i-lucide-shield-alert",{"title":122,"path":123,"stem":124,"children":125,"icon":127},"Rate limiting","\u002Frate-limiting","6.rate-limiting\u002F1.index",[126],{"title":122,"path":123,"stem":124,"icon":127},"i-lucide-gauge",{"title":129,"icon":130,"path":131,"stem":132,"children":133,"page":55},"Reference","i-lucide-book-marked","\u002Freference","7.reference",[134,139],{"title":135,"path":136,"stem":137,"icon":138},"Feature flags","\u002Freference\u002Ffeature-flags","7.reference\u002F1.feature-flags","i-lucide-flag",{"title":140,"path":141,"stem":142,"icon":143},"API reference","\u002Freference\u002Fapi","7.reference\u002F2.api","i-lucide-file-code",{"title":145,"path":146,"stem":147,"children":148,"icon":150},"Changelog","\u002Fchangelog","8.changelog\u002F1.index",[149],{"title":145,"path":146,"stem":147,"icon":150},"i-lucide-scroll",{"id":152,"title":117,"badge":153,"body":154,"date":153,"description":752,"extension":753,"links":153,"meta":754,"navigation":755,"path":118,"seo":756,"stem":119,"__hash__":757},"docs\u002F5.locks\u002F5.guard-state.md",null,{"type":155,"value":156,"toc":747},"minimark",[157,166,170,241,255,342,346,352,539,543,557,581,730,743],[158,159,160,161,165],"p",{},"A lock guard tracks the state of its lease. Because the lease renews in the background, it's possible (rarely) for a guard to lose its lease mid-section - for instance, if Redis was briefly unreachable past the ttl. ",[162,163,164],"code",{},"LockGuardState"," lets you observe that.",[167,168,164],"h2",{"id":169},"lockguardstate",[171,172,177],"pre",{"className":173,"code":174,"language":175,"meta":176,"style":176},"language-rust shiki shiki-themes material-theme-lighter github-light github-dark","pub enum LockGuardState {\n    Acquired, \u002F\u002F held, lease is being renewed\n    Lost,     \u002F\u002F a refresh failed; the lease is presumed gone (may still recover)\n    Released, \u002F\u002F released, no longer held\n}\n","rust","",[162,178,179,200,213,224,235],{"__ignoreMap":176},[180,181,184,188,192,196],"span",{"class":182,"line":183},"line",1,[180,185,187],{"class":186},"sw1J6","pub",[180,189,191],{"class":190},"sbsja"," enum",[180,193,195],{"class":194},"sbgvK"," LockGuardState",[180,197,199],{"class":198},"sP7_E"," {\n",[180,201,203,206,209],{"class":182,"line":202},2,[180,204,205],{"class":194},"    Acquired",[180,207,208],{"class":198},",",[180,210,212],{"class":211},"sutJx"," \u002F\u002F held, lease is being renewed\n",[180,214,216,219,221],{"class":182,"line":215},3,[180,217,218],{"class":194},"    Lost",[180,220,208],{"class":198},[180,222,223],{"class":211},"     \u002F\u002F a refresh failed; the lease is presumed gone (may still recover)\n",[180,225,227,230,232],{"class":182,"line":226},4,[180,228,229],{"class":194},"    Released",[180,231,208],{"class":198},[180,233,234],{"class":211}," \u002F\u002F released, no longer held\n",[180,236,238],{"class":182,"line":237},5,[180,239,240],{"class":198},"}\n",[158,242,243,244,247,248,247,251,254],{},"Every guard - ",[162,245,246],{},"MutexGuard",", ",[162,249,250],{},"RwLockReadGuard",[162,252,253],{},"RwLockWriteGuard"," - exposes:",[171,256,258],{"className":173,"code":257,"language":175,"meta":176,"style":176},"\u002F\u002F Inspect the current state. No Redis round-trip.\nasync fn get_state(&self) -> LockGuardState;\n\n\u002F\u002F Release explicitly and return the resulting state.\nasync fn release(self) -> Result\u003CLockGuardState, DistkitError>;\n",[162,259,260,265,299,304,309],{"__ignoreMap":176},[180,261,262],{"class":182,"line":183},[180,263,264],{"class":211},"\u002F\u002F Inspect the current state. No Redis round-trip.\n",[180,266,267,270,273,277,280,284,288,291,294,296],{"class":182,"line":202},[180,268,269],{"class":186},"async",[180,271,272],{"class":186}," fn",[180,274,276],{"class":275},"sGLFI"," get_state",[180,278,279],{"class":198},"(",[180,281,283],{"class":282},"smGrS","&",[180,285,287],{"class":286},"s_hVV","self",[180,289,290],{"class":198},")",[180,292,293],{"class":282}," ->",[180,295,195],{"class":194},[180,297,298],{"class":198},";\n",[180,300,301],{"class":182,"line":215},[180,302,303],{"emptyLinePlaceholder":28},"\n",[180,305,306],{"class":182,"line":226},[180,307,308],{"class":211},"\u002F\u002F Release explicitly and return the resulting state.\n",[180,310,311,313,315,318,320,322,324,326,329,332,334,336,339],{"class":182,"line":237},[180,312,269],{"class":186},[180,314,272],{"class":186},[180,316,317],{"class":275}," release",[180,319,279],{"class":198},[180,321,287],{"class":286},[180,323,290],{"class":198},[180,325,293],{"class":282},[180,327,328],{"class":194}," Result",[180,330,331],{"class":198},"\u003C",[180,333,164],{"class":194},[180,335,208],{"class":198},[180,337,338],{"class":194}," DistkitError",[180,340,341],{"class":198},">;\n",[167,343,345],{"id":344},"checking-before-a-critical-section","Checking before a critical section",[158,347,348,351],{},[162,349,350],{},"Lost"," is the state to guard against: it means the lock may no longer be exclusively yours.",[171,353,355],{"className":173,"code":354,"language":175,"meta":176,"style":176},"use distkit::lock::LockGuardState;\n\nlet guard = mutex.lock().await?;\n\nmatch guard.get_state().await {\n    LockGuardState::Acquired => {\n        \u002F\u002F safe - do the protected work\n    }\n    LockGuardState::Lost => {\n        \u002F\u002F lease slipped; bail out instead of risking a double-run\n        return Ok(());\n    }\n    LockGuardState::Released => unreachable!(\"we still hold the guard\"),\n}\n",[162,356,357,377,381,415,419,440,456,462,468,481,487,499,504,534],{"__ignoreMap":176},[180,358,359,362,365,368,371,373,375],{"class":182,"line":183},[180,360,361],{"class":186},"use",[180,363,364],{"class":194}," distkit",[180,366,367],{"class":282},"::",[180,369,370],{"class":194},"lock",[180,372,367],{"class":282},[180,374,164],{"class":194},[180,376,298],{"class":198},[180,378,379],{"class":182,"line":202},[180,380,303],{"emptyLinePlaceholder":28},[180,382,383,386,390,393,396,399,401,404,406,410,413],{"class":182,"line":215},[180,384,385],{"class":190},"let",[180,387,389],{"class":388},"su5hD"," guard ",[180,391,392],{"class":282},"=",[180,394,395],{"class":388}," mutex",[180,397,398],{"class":282},".",[180,400,370],{"class":275},[180,402,403],{"class":198},"()",[180,405,398],{"class":282},[180,407,409],{"class":408},"sVHd0","await",[180,411,412],{"class":282},"?",[180,414,298],{"class":198},[180,416,417],{"class":182,"line":226},[180,418,303],{"emptyLinePlaceholder":28},[180,420,421,424,427,429,432,434,436,438],{"class":182,"line":237},[180,422,423],{"class":408},"match",[180,425,426],{"class":388}," guard",[180,428,398],{"class":282},[180,430,431],{"class":275},"get_state",[180,433,403],{"class":198},[180,435,398],{"class":282},[180,437,409],{"class":408},[180,439,199],{"class":198},[180,441,443,446,448,451,454],{"class":182,"line":442},6,[180,444,445],{"class":194},"    LockGuardState",[180,447,367],{"class":282},[180,449,450],{"class":194},"Acquired",[180,452,453],{"class":282}," =>",[180,455,199],{"class":198},[180,457,459],{"class":182,"line":458},7,[180,460,461],{"class":211},"        \u002F\u002F safe - do the protected work\n",[180,463,465],{"class":182,"line":464},8,[180,466,467],{"class":198},"    }\n",[180,469,471,473,475,477,479],{"class":182,"line":470},9,[180,472,445],{"class":194},[180,474,367],{"class":282},[180,476,350],{"class":194},[180,478,453],{"class":282},[180,480,199],{"class":198},[180,482,484],{"class":182,"line":483},10,[180,485,486],{"class":211},"        \u002F\u002F lease slipped; bail out instead of risking a double-run\n",[180,488,490,493,496],{"class":182,"line":489},11,[180,491,492],{"class":408},"        return",[180,494,495],{"class":194}," Ok",[180,497,498],{"class":198},"(());\n",[180,500,502],{"class":182,"line":501},12,[180,503,467],{"class":198},[180,505,507,509,511,514,516,519,521,525,529,531],{"class":182,"line":506},13,[180,508,445],{"class":194},[180,510,367],{"class":282},[180,512,513],{"class":194},"Released",[180,515,453],{"class":282},[180,517,518],{"class":275}," unreachable!",[180,520,279],{"class":198},[180,522,524],{"class":523},"sjJ54","\"",[180,526,528],{"class":527},"s_sjI","we still hold the guard",[180,530,524],{"class":523},[180,532,533],{"class":198},"),\n",[180,535,537],{"class":182,"line":536},14,[180,538,240],{"class":198},[167,540,542],{"id":541},"acquisition-errors","Acquisition errors",[158,544,545,546,552,553,556],{},"Acquiring can fail with a ",[547,548,549],"a",{"href":52},[162,550,551],{},"LockError"," (surfaced as ",[162,554,555],{},"DistkitError::LockError","). The two you handle routinely mean \"the lock is busy\", not \"something broke\":",[558,559,560,571],"ul",{},[561,562,563,566,567,570],"li",{},[162,564,565],{},"AcquireFail"," - a non-blocking ",[162,568,569],{},"try_*"," call would have had to wait.",[561,572,573,576,577,580],{},[162,574,575],{},"Timeout { waited }"," - a bounded ",[162,578,579],{},"*_for"," call ran out of time.",[171,582,584],{"className":173,"code":583,"language":175,"meta":176,"style":176},"use distkit::{DistkitError, lock::LockError};\n\nmatch mutex.try_lock().await {\n    Ok(guard) => { \u002F* got it *\u002F }\n    Err(DistkitError::LockError(LockError::AcquireFail)) => {\n        \u002F\u002F someone else holds it - back off and retry later\n    }\n    Err(e) => return Err(e.into()),\n}\n",[162,585,586,612,616,635,658,686,691,695,726],{"__ignoreMap":176},[180,587,588,590,592,594,597,600,602,605,607,609],{"class":182,"line":183},[180,589,361],{"class":186},[180,591,364],{"class":194},[180,593,367],{"class":282},[180,595,596],{"class":198},"{",[180,598,599],{"class":194},"DistkitError",[180,601,208],{"class":198},[180,603,604],{"class":194}," lock",[180,606,367],{"class":282},[180,608,551],{"class":194},[180,610,611],{"class":198},"};\n",[180,613,614],{"class":182,"line":202},[180,615,303],{"emptyLinePlaceholder":28},[180,617,618,620,622,624,627,629,631,633],{"class":182,"line":215},[180,619,423],{"class":408},[180,621,395],{"class":388},[180,623,398],{"class":282},[180,625,626],{"class":275},"try_lock",[180,628,403],{"class":198},[180,630,398],{"class":282},[180,632,409],{"class":408},[180,634,199],{"class":198},[180,636,637,640,642,645,647,649,652,655],{"class":182,"line":226},[180,638,639],{"class":194},"    Ok",[180,641,279],{"class":198},[180,643,644],{"class":388},"guard",[180,646,290],{"class":198},[180,648,453],{"class":282},[180,650,651],{"class":198}," {",[180,653,654],{"class":211}," \u002F* got it *\u002F",[180,656,657],{"class":198}," }\n",[180,659,660,663,665,667,669,671,673,675,677,679,682,684],{"class":182,"line":237},[180,661,662],{"class":194},"    Err",[180,664,279],{"class":198},[180,666,599],{"class":194},[180,668,367],{"class":282},[180,670,551],{"class":275},[180,672,279],{"class":198},[180,674,551],{"class":194},[180,676,367],{"class":282},[180,678,565],{"class":194},[180,680,681],{"class":198},"))",[180,683,453],{"class":282},[180,685,199],{"class":198},[180,687,688],{"class":182,"line":442},[180,689,690],{"class":211},"        \u002F\u002F someone else holds it - back off and retry later\n",[180,692,693],{"class":182,"line":458},[180,694,467],{"class":198},[180,696,697,699,701,704,706,708,711,714,716,718,720,723],{"class":182,"line":464},[180,698,662],{"class":194},[180,700,279],{"class":198},[180,702,703],{"class":388},"e",[180,705,290],{"class":198},[180,707,453],{"class":282},[180,709,710],{"class":408}," return",[180,712,713],{"class":194}," Err",[180,715,279],{"class":198},[180,717,703],{"class":388},[180,719,398],{"class":282},[180,721,722],{"class":275},"into",[180,724,725],{"class":198},"()),\n",[180,727,728],{"class":182,"line":470},[180,729,240],{"class":198},[158,731,732,733,247,736,247,739,742],{},"The remaining variants (",[162,734,735],{},"NotOwner",[162,737,738],{},"InvalidTtl",[162,740,741],{},"InvalidOwner",") indicate misuse or bad configuration rather than contention.",[744,745,746],"style",{},"html pre.shiki code .sw1J6, html code.shiki .sw1J6{--shiki-light:#F76D47;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}",{"title":176,"searchDepth":183,"depth":202,"links":748},[749,750,751],{"id":169,"depth":202,"text":164},{"id":344,"depth":202,"text":345},{"id":541,"depth":202,"text":542},"Reading a guard's lease state and handling acquisition failures.","md",{},{"icon":120},{"title":117,"description":752},"ioyg-7dQAoEsUBZckbqhal0KiGw4sK95o5AQYTTjA8M",[759,761],{"title":112,"path":113,"stem":114,"description":760,"icon":115,"children":-1},"Tune TTL, owner, wait bounds, and namespace via LockOptions and its builder.",{"title":122,"path":123,"stem":124,"description":762,"icon":127,"children":-1},"Sliding-window rate limiting via the trypema crate, re-exported under distkit::trypema.",1781569583369]