Skip to content

Commit 72da14a

Browse files
committed
Bump to version 25.03.05 (matrix-rust-sdk/main 8d8846a259797a02e37d99dd52e4331260dc3338)
1 parent f42b210 commit 72da14a

File tree

3 files changed

+437
-105
lines changed

3 files changed

+437
-105
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// swift-tools-version:5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
import PackageDescription
4-
let checksum = "96ab741ee37d6d16033d95bbe4c09f2cca9d1dc3854076b84ff886aa687d574d"
5-
let version = "25.02.28"
4+
let checksum = "7647b400ad5c80a63acdfe18cb909bcea67470303344ab0be91af6d3fe7f05cd"
5+
let version = "25.03.05"
66
let url = "https://github.com/element-hq/matrix-rust-components-swift/releases/download/\(version)/MatrixSDKFFI.xcframework.zip"
77
let package = Package(
88
name: "MatrixRustSDK",

Sources/MatrixRustSDK/matrix_sdk_base.swift

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,19 @@ fileprivate class UniffiHandleMap<T> {
382382
// Public interface members begin here.
383383

384384

385+
fileprivate struct FfiConverterUInt64: FfiConverterPrimitive {
386+
typealias FfiType = UInt64
387+
typealias SwiftType = UInt64
388+
389+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
390+
return try lift(readInt(&buf))
391+
}
392+
393+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
394+
writeInt(&buf, lower(value))
395+
}
396+
}
397+
385398
fileprivate struct FfiConverterString: FfiConverter {
386399
typealias SwiftType = String
387400
typealias FfiType = RustBuffer
@@ -420,6 +433,255 @@ fileprivate struct FfiConverterString: FfiConverter {
420433
}
421434
}
422435

436+
fileprivate struct FfiConverterDuration: FfiConverterRustBuffer {
437+
typealias SwiftType = TimeInterval
438+
439+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TimeInterval {
440+
let seconds: UInt64 = try readInt(&buf)
441+
let nanoseconds: UInt32 = try readInt(&buf)
442+
return Double(seconds) + (Double(nanoseconds) / 1.0e9)
443+
}
444+
445+
public static func write(_ value: TimeInterval, into buf: inout [UInt8]) {
446+
if value.rounded(.down) > Double(Int64.max) {
447+
fatalError("Duration overflow, exceeds max bounds supported by Uniffi")
448+
}
449+
450+
if value < 0 {
451+
fatalError("Invalid duration, must be non-negative")
452+
}
453+
454+
let seconds = UInt64(value)
455+
let nanoseconds = UInt32((value - Double(seconds)) * 1.0e9)
456+
writeInt(&buf, seconds)
457+
writeInt(&buf, nanoseconds)
458+
}
459+
}
460+
461+
462+
/**
463+
* The retention policy for media content used by the [`EventCacheStore`].
464+
*
465+
* [`EventCacheStore`]: crate::event_cache::store::EventCacheStore
466+
*/
467+
public struct MediaRetentionPolicy {
468+
/**
469+
* The maximum authorized size of the overall media cache, in bytes.
470+
*
471+
* The cache size is defined as the sum of the sizes of all the (possibly
472+
* encrypted) media contents in the cache, excluding any metadata
473+
* associated with them.
474+
*
475+
* If this is set and the cache size is bigger than this value, the oldest
476+
* media contents in the cache will be removed during a cleanup until the
477+
* cache size is below this threshold.
478+
*
479+
* Note that it is possible for the cache size to temporarily exceed this
480+
* value between two cleanups.
481+
*
482+
* Defaults to 400 MiB.
483+
*/
484+
public var maxCacheSize: UInt64?
485+
/**
486+
* The maximum authorized size of a single media content, in bytes.
487+
*
488+
* The size of a media content is the size taken by the content in the
489+
* database, after it was possibly encrypted, so it might differ from the
490+
* initial size of the content.
491+
*
492+
* The maximum authorized size of a single media content is actually the
493+
* lowest value between `max_cache_size` and `max_file_size`.
494+
*
495+
* If it is set, media content bigger than the maximum size will not be
496+
* cached. If the maximum size changed after media content that exceeds the
497+
* new value was cached, the corresponding content will be removed
498+
* during a cleanup.
499+
*
500+
* Defaults to 20 MiB.
501+
*/
502+
public var maxFileSize: UInt64?
503+
/**
504+
* The duration after which unaccessed media content is considered
505+
* expired.
506+
*
507+
* If this is set, media content whose last access is older than this
508+
* duration will be removed from the media cache during a cleanup.
509+
*
510+
* Defaults to 60 days.
511+
*/
512+
public var lastAccessExpiry: TimeInterval?
513+
/**
514+
* The duration between two automatic media cache cleanups.
515+
*
516+
* If this is set, a cleanup will be triggered after the given duration
517+
* is elapsed, at the next call to the media cache API. If this is set to
518+
* zero, each call to the media cache API will trigger a cleanup. If this
519+
* is `None`, cleanups will only occur if they are triggered manually.
520+
*
521+
* Defaults to running cleanups daily.
522+
*/
523+
public var cleanupFrequency: TimeInterval?
524+
525+
// Default memberwise initializers are never public by default, so we
526+
// declare one manually.
527+
public init(
528+
/**
529+
* The maximum authorized size of the overall media cache, in bytes.
530+
*
531+
* The cache size is defined as the sum of the sizes of all the (possibly
532+
* encrypted) media contents in the cache, excluding any metadata
533+
* associated with them.
534+
*
535+
* If this is set and the cache size is bigger than this value, the oldest
536+
* media contents in the cache will be removed during a cleanup until the
537+
* cache size is below this threshold.
538+
*
539+
* Note that it is possible for the cache size to temporarily exceed this
540+
* value between two cleanups.
541+
*
542+
* Defaults to 400 MiB.
543+
*/maxCacheSize: UInt64?,
544+
/**
545+
* The maximum authorized size of a single media content, in bytes.
546+
*
547+
* The size of a media content is the size taken by the content in the
548+
* database, after it was possibly encrypted, so it might differ from the
549+
* initial size of the content.
550+
*
551+
* The maximum authorized size of a single media content is actually the
552+
* lowest value between `max_cache_size` and `max_file_size`.
553+
*
554+
* If it is set, media content bigger than the maximum size will not be
555+
* cached. If the maximum size changed after media content that exceeds the
556+
* new value was cached, the corresponding content will be removed
557+
* during a cleanup.
558+
*
559+
* Defaults to 20 MiB.
560+
*/maxFileSize: UInt64?,
561+
/**
562+
* The duration after which unaccessed media content is considered
563+
* expired.
564+
*
565+
* If this is set, media content whose last access is older than this
566+
* duration will be removed from the media cache during a cleanup.
567+
*
568+
* Defaults to 60 days.
569+
*/lastAccessExpiry: TimeInterval?,
570+
/**
571+
* The duration between two automatic media cache cleanups.
572+
*
573+
* If this is set, a cleanup will be triggered after the given duration
574+
* is elapsed, at the next call to the media cache API. If this is set to
575+
* zero, each call to the media cache API will trigger a cleanup. If this
576+
* is `None`, cleanups will only occur if they are triggered manually.
577+
*
578+
* Defaults to running cleanups daily.
579+
*/cleanupFrequency: TimeInterval?) {
580+
self.maxCacheSize = maxCacheSize
581+
self.maxFileSize = maxFileSize
582+
self.lastAccessExpiry = lastAccessExpiry
583+
self.cleanupFrequency = cleanupFrequency
584+
}
585+
}
586+
587+
588+
589+
extension MediaRetentionPolicy: Equatable, Hashable {
590+
public static func ==(lhs: MediaRetentionPolicy, rhs: MediaRetentionPolicy) -> Bool {
591+
if lhs.maxCacheSize != rhs.maxCacheSize {
592+
return false
593+
}
594+
if lhs.maxFileSize != rhs.maxFileSize {
595+
return false
596+
}
597+
if lhs.lastAccessExpiry != rhs.lastAccessExpiry {
598+
return false
599+
}
600+
if lhs.cleanupFrequency != rhs.cleanupFrequency {
601+
return false
602+
}
603+
return true
604+
}
605+
606+
public func hash(into hasher: inout Hasher) {
607+
hasher.combine(maxCacheSize)
608+
hasher.combine(maxFileSize)
609+
hasher.combine(lastAccessExpiry)
610+
hasher.combine(cleanupFrequency)
611+
}
612+
}
613+
614+
615+
public struct FfiConverterTypeMediaRetentionPolicy: FfiConverterRustBuffer {
616+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MediaRetentionPolicy {
617+
return
618+
try MediaRetentionPolicy(
619+
maxCacheSize: FfiConverterOptionUInt64.read(from: &buf),
620+
maxFileSize: FfiConverterOptionUInt64.read(from: &buf),
621+
lastAccessExpiry: FfiConverterOptionDuration.read(from: &buf),
622+
cleanupFrequency: FfiConverterOptionDuration.read(from: &buf)
623+
)
624+
}
625+
626+
public static func write(_ value: MediaRetentionPolicy, into buf: inout [UInt8]) {
627+
FfiConverterOptionUInt64.write(value.maxCacheSize, into: &buf)
628+
FfiConverterOptionUInt64.write(value.maxFileSize, into: &buf)
629+
FfiConverterOptionDuration.write(value.lastAccessExpiry, into: &buf)
630+
FfiConverterOptionDuration.write(value.cleanupFrequency, into: &buf)
631+
}
632+
}
633+
634+
635+
public func FfiConverterTypeMediaRetentionPolicy_lift(_ buf: RustBuffer) throws -> MediaRetentionPolicy {
636+
return try FfiConverterTypeMediaRetentionPolicy.lift(buf)
637+
}
638+
639+
public func FfiConverterTypeMediaRetentionPolicy_lower(_ value: MediaRetentionPolicy) -> RustBuffer {
640+
return FfiConverterTypeMediaRetentionPolicy.lower(value)
641+
}
642+
643+
fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer {
644+
typealias SwiftType = UInt64?
645+
646+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
647+
guard let value = value else {
648+
writeInt(&buf, Int8(0))
649+
return
650+
}
651+
writeInt(&buf, Int8(1))
652+
FfiConverterUInt64.write(value, into: &buf)
653+
}
654+
655+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
656+
switch try readInt(&buf) as Int8 {
657+
case 0: return nil
658+
case 1: return try FfiConverterUInt64.read(from: &buf)
659+
default: throw UniffiInternalError.unexpectedOptionalTag
660+
}
661+
}
662+
}
663+
664+
fileprivate struct FfiConverterOptionDuration: FfiConverterRustBuffer {
665+
typealias SwiftType = TimeInterval?
666+
667+
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
668+
guard let value = value else {
669+
writeInt(&buf, Int8(0))
670+
return
671+
}
672+
writeInt(&buf, Int8(1))
673+
FfiConverterDuration.write(value, into: &buf)
674+
}
675+
676+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
677+
switch try readInt(&buf) as Int8 {
678+
case 0: return nil
679+
case 1: return try FfiConverterDuration.read(from: &buf)
680+
default: throw UniffiInternalError.unexpectedOptionalTag
681+
}
682+
}
683+
}
684+
423685
private enum InitializationResult {
424686
case ok
425687
case contractVersionMismatch

0 commit comments

Comments
 (0)