Skip to main content

rustfs_storage_api/
lib.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Storage API contracts for RustFS.
16
17pub const WALK_DIR_STREAM_COMPLETION_QUERY: &str = "walk_dir_stream_completion";
18pub const WALK_DIR_STREAM_COMPLETION_V1: &str = "error-v1";
19pub const WALK_DIR_BODY_SHA256_QUERY: &str = "walk_dir_body_sha256";
20pub const PUT_FILE_AUTH_QUERY: &str = "put_file_auth";
21pub const PUT_FILE_AUTH_V1: &str = "digest-trailer-v1";
22pub const PUT_FILE_NONCE_QUERY: &str = "put_file_nonce";
23pub const PUT_FILE_CAPABILITY_QUERY: &str = "put_file_capability";
24pub const PUT_FILE_CAPABILITY_CHALLENGE_QUERY: &str = "put_file_challenge";
25pub const PUT_FILE_CAPABILITY_VERSION: u16 = 1;
26pub const PUT_FILE_SERVER_EPOCH_QUERY: &str = "put_file_server_epoch";
27pub const PUT_FILE_AUTH_TRAILER_MAGIC: &[u8; 16] = b"RFS-PUT-AUTH-V1\0";
28pub const PUT_FILE_AUTH_TRAILER_DIGEST_LEN: usize = 64;
29pub const PUT_FILE_AUTH_TRAILER_MAC_LEN: usize = 32;
30pub const PUT_FILE_AUTH_TRAILER_LEN: usize =
31    PUT_FILE_AUTH_TRAILER_MAGIC.len() + PUT_FILE_AUTH_TRAILER_DIGEST_LEN + PUT_FILE_AUTH_TRAILER_MAC_LEN;
32
33#[derive(Debug, serde::Deserialize, serde::Serialize)]
34#[serde(deny_unknown_fields)]
35pub struct PutFileCapabilityResponse {
36    pub version: u16,
37    pub server_epoch: uuid::Uuid,
38    pub proof: Vec<u8>,
39}
40pub const NS_SCANNER_BODY_SHA256_QUERY: &str = "ns_scanner_body_sha256";
41pub const NS_SCANNER_CAPABILITY_CHALLENGE_QUERY: &str = "ns_scanner_challenge";
42pub const NS_SCANNER_CYCLE_QUERY: &str = "ns_scanner_cycle";
43pub const NS_SCANNER_LEADER_EPOCH_QUERY: &str = "ns_scanner_leader_epoch";
44pub const NS_SCANNER_REQUEST_ID_QUERY: &str = "ns_scanner_request_id";
45pub const NS_SCANNER_SERVER_EPOCH_QUERY: &str = "ns_scanner_server_epoch";
46pub const NS_SCANNER_SESSION_ID_QUERY: &str = "ns_scanner_session_id";
47pub const NS_SCANNER_SESSION_SEQUENCE_QUERY: &str = "ns_scanner_session_sequence";
48pub const NS_SCANNER_PROTOCOL_VERSION_QUERY: &str = "ns_scanner_protocol";
49pub const NS_SCANNER_TIER_REGISTRY_GENERATION_QUERY: &str = "ns_scanner_tier_registry_generation";
50pub const NS_SCANNER_PROTOCOL_VERSION: u16 = 3;
51pub const SCANNER_ACTIVITY_LEGACY_PROTOCOL_VERSION: u32 = 0;
52pub const SCANNER_ACTIVITY_PREVIOUS_PROTOCOL_VERSION: u32 = 5;
53/// Protocol v6 carries the activity fields that predate the storage-owned
54/// movement generation.  It remains readable during the rolling upgrade, but
55/// a scanner must not use it as a publication proof because terminal movement
56/// state is not authenticated by that version.
57pub const SCANNER_ACTIVITY_V6_PROTOCOL_VERSION: u32 = 6;
58pub const SCANNER_ACTIVITY_PROTOCOL_VERSION: u32 = 7;
59pub const SCANNER_DIRTY_USAGE_SNAPSHOT_PROTOCOL_VERSION: u32 = 2;
60pub const SCANNER_SCOPED_DIRTY_USAGE_ACK_MAX_ENTRIES: usize = 32;
61pub const SCANNER_DIRTY_USAGE_SNAPSHOT_MAX_ENTRIES: usize = SCANNER_SCOPED_DIRTY_USAGE_ACK_MAX_ENTRIES;
62pub const SCANNER_DIRTY_USAGE_SNAPSHOT_RPC_MAX_MESSAGE_SIZE: usize = 512 * 1024;
63
64#[derive(Debug, serde::Deserialize, serde::Serialize)]
65#[serde(deny_unknown_fields)]
66pub struct NsScannerCapabilityResponse {
67    pub version: u16,
68    pub server_epoch: uuid::Uuid,
69    pub proof: Vec<u8>,
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    pub supports_tier_registry_generation: Option<bool>,
72}
73
74pub mod admin;
75pub mod bucket;
76pub mod capability;
77pub mod error;
78pub mod multipart;
79pub mod object;
80pub mod observability;
81pub mod topology;
82
83mod replication;
84
85pub use admin::{DiskSetSelector, StorageAdminApi};
86pub use bucket::BUCKET_LIFECYCLE_LOCK_OBJECT;
87pub use bucket::{BucketInfo, BucketOperations, BucketOptions, DeleteBucketOptions, MakeBucketOptions, SRBucketDeleteOp};
88pub use capability::{CapabilitySnapshotError, CapabilityState, CapabilityStatus};
89pub use error::{StorageErrorCode, StorageResult};
90pub use multipart::{CompletePart, ListMultipartsInfo, ListPartsInfo, MultipartInfo, MultipartUploadResult, PartInfo};
91pub use object::DeleteAccounting;
92pub use object::ObjectLockDeleteOptions;
93pub use object::ObjectToDeleteIdentity;
94pub use object::{DeletedObject, ObjectToDelete};
95pub use object::{ExpirationOptions, TransitionedObject};
96pub use object::{HTTPPreconditions, HTTPRangeError, HTTPRangeSpec, ObjectLockRetentionOptions};
97pub use object::{HealOperations, MultipartOperations, NamespaceLocking, ObjectIO, ObjectOperations};
98pub use object::{ListObjectVersionsInfo, ListObjectsInfo, ListObjectsV2Info, ListOperations, ObjectInfoOrErr};
99pub use object::{ObjectPreconditionError, ObjectPreconditionPart, ObjectPreconditionState};
100pub use object::{VersionMarker, WalkOptions, WalkVersionsSortOrder};
101pub use observability::{
102    MemorySamplingState, ObservabilitySnapshot, ObservabilitySnapshotProvider, PlatformSupport, UserspaceProfilingCapability,
103};
104/// Object-metadata keys persisted in xl.meta `meta_user`. filemeta owns the
105/// on-disk spelling; contract consumers that read or write persisted object
106/// metadata (lifecycle object-lock checks) take the keys from here.
107pub use rustfs_filemeta::metadata_keys;
108pub use topology::{
109    DiskCapabilities, TopologyCapabilities, TopologyDisk, TopologyLabels, TopologyPool, TopologySet, TopologySnapshot,
110    TopologySnapshotProvider,
111};