pub trait FileStorage: Send + Sync {
// Provided methods
fn read_stream(
&self,
_start: u64,
_count: u64,
) -> Result<FileStreamRead, Error> { ... }
fn write_stream(
&mut self,
_start: FileWriteStart,
_data: &[u8],
) -> Result<u64, Error> { ... }
fn read_records(
&self,
_start: u64,
_count: u64,
) -> Result<FileRecordRead, Error> { ... }
fn write_records(
&mut self,
_start: FileWriteStart,
_records: &[Vec<u8>],
) -> Result<u64, Error> { ... }
}Expand description
The octet- and record-addressed storage behind a File object.
This is the internal channel AtomicReadFile and AtomicWriteFile use
to reach file contents (Clauses 14.1 and 14.2). It is deliberately not a
property: Table 12-16 (Clause 12.13) defines no File Data property, so
file contents have no network route other than the File Access Services,
and nothing here appears in Property_List.
The server reaches an implementation through
BACnetObject::file_storage_internal and
BACnetObject::file_storage_internal_mut. Every method has a default
that refuses with SERVICES / FILE_ACCESS_DENIED — there is no
implementation behind it, making the file inaccessible under
Clause 18 — and a stream-only implementation overrides only the
two stream methods.
Error contract, using the Clause 14 pairs:
- SERVICES / INVALID_FILE_START_POSITION when a read starts past the
current end (Clause 14.1 Service Procedure). Reading at the end is
legal and yields an empty window. The built-in empty file reports
end_of_fileTRUE there; non-empty files report FALSE for such a window. - OBJECT / FILE_FULL when a write would grow the file past the most this implementation can hold (Clause 14.2.4.1; Clause 18).
- SERVICES / INVALID_FILE_ACCESS_METHOD when the method does not match
the object’s
File_Access_Method; only a genuine mismatch, never a missing implementation, reports this. - SERVICES / FILE_ACCESS_DENIED from the defaults above.
A write that returns Err must leave the storage unchanged: the service
fails as a whole (Clause 14.2.4), and the server encodes no ACK on
the error path. Resolved write positions must fit the ACK’s INTEGER, so
implementations keep their limit at or below i32::MAX.
Provided Methods§
Sourcefn read_stream(&self, _start: u64, _count: u64) -> Result<FileStreamRead, Error>
fn read_stream(&self, _start: u64, _count: u64) -> Result<FileStreamRead, Error>
Read up to count octets starting start octets into the file.
Sourcefn write_stream(
&mut self,
_start: FileWriteStart,
_data: &[u8],
) -> Result<u64, Error>
fn write_stream( &mut self, _start: FileWriteStart, _data: &[u8], ) -> Result<u64, Error>
Write data at start, extending the file first when start is
past the end; intervening octets are a local matter. Returns the
octet offset the data was written at, which for
FileWriteStart::Append is the previous file size.
Sourcefn read_records(
&self,
_start: u64,
_count: u64,
) -> Result<FileRecordRead, Error>
fn read_records( &self, _start: u64, _count: u64, ) -> Result<FileRecordRead, Error>
Read up to count records starting at record start.
Sourcefn write_records(
&mut self,
_start: FileWriteStart,
_records: &[Vec<u8>],
) -> Result<u64, Error>
fn write_records( &mut self, _start: FileWriteStart, _records: &[Vec<u8>], ) -> Result<u64, Error>
Write records starting at record start, replacing records in
place and extending the file first when start is past the end.
Returns the record index the data was written at.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".